11-01-2012 09:23 AM
Hi, thanks for your continued support BGmot.
All my relevent java stuff is nicely pasted here now if that helps..
11-01-2012 09:25 AM - edited 11-01-2012 09:26 AM
Sorry BGmot, just understood your question.
out is the output stream to the socket and dout is the dataoutputstream to the socket. dout writes the size of the bytes to be expected which is converted to toRead in c++.
Thanks.
11-01-2012 09:40 AM
>out is the output stream to the socket and dout is the dataoutputstream to the socket.
Ok, I don't know Java and don't really understand what that means -))) disregard my question, hope you are writing to the socket properly.
let's rewrite your Java this way:
byte[] integersToBytes(int[] values)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
for(int i=0; i < values.length; ++i)
{
try
{
dos.writeByte((values[i] >> 16) & 0xff); // R
dos.writeByte((values[i] >> 8) & 0xff); // G
dos.writeByte(values[i] & 0xff); // B
dos.writeByte((values[i] >> 24) & 0xff); // A
}
catch(Exception gg)
{
}
}
return baos.toByteArray();
}
And your C code should be something like this:
int w = 50;
int h = 50;
int toRead = w*h*4;
int pixels[toRead];
int readInt;
char buf2[4];
while(connected){
toRead = readImageSize(imagesock, buf2, sizeof(buf2));
char image_data[toRead];
bzero(image_data, toRead);
totalBytes = 0;
received = 0;
while (connected && totalBytes < toRead){
received = read(imagesock, &image_data[totalBytes], sizeof(image_data)-totalBytes);
if(received > 0){
totalBytes += received;
}
}
cout << "\n totalbytes " << totalBytes << "toread=" << toRead;
cout.flush();
for (int i=0; i < h; i++)
memcpy(img.access.direct.data+i*img.access.direct. stride, image_data, w*4);
screen_post_window(screen, bg_buf, 1, rect, 0 ); screen_flush_context(screencontext,0); }
11-01-2012 10:04 AM
just a quick update BGmot, the size of the image is a square now (thanks) which is correct but the exact same color issues remain.
I have just set my screen to 1024x600 in case that affected things but it didnt at all in terms of color.
I wonder what else could be doing this - if I had to speculate what was happening I'd say the image could be display a lot bigger than it actually is so a bit of blue is filling the whole square.
11-01-2012 10:07 AM
Please send me (via PM) raw output - bytes you are receiving from socket, Several hundreds will be enough.
11-01-2012 10:09 AM
First lets simplify this issue. You probably should elimiate the server/socket from this equation until you have it working on the device first. Take your sample image, get the ARGB byte array and write it to a file. One the device use that file locally for now. If you want others to help test it you could also attach here a zip of the image and the file containing the ARGB bytes. If you attach the zip with both, someone else can also confirm if its correct output.
11-01-2012 11:45 AM
BGmot, I'm about to pm you the first few hundrew characters of my file, should I pm it to you to mreed - I can't find an attach zip option when replying?
11-01-2012 12:43 PM
There should be an Attachments option to the right of where you type your reply. Not really interested in a partial file though.
11-01-2012 12:56 PM
I really cant see an option to attach - maybe because we're different levels we have different privileges?
11-02-2012 11:50 AM - edited 11-02-2012 11:51 AM
Interesting. I'm not sure why its not there. Find a file host I guess?
I think you can confirm yourself if the ARGB int[] is correct by just converting it back to a Bitmap or PNG and save it to a file. Thats the first thing you should confirm.