10-31-2012 06:20 PM
I don't think that we have one byte per pixel ratio.
Please landscape orient your PlayBook and do this to find out how many bytes in screen buffer allocated per pixel.
int nStride = 0; int nBytesPerPixel = 0; int nScreenWidth = 1024; screen_get_buffer_property_iv(screen_buf, SCREEN_PROPERTY_STRIDE, &nStride); nBytesPerPixel = nStride/nScreenWidth;
10-31-2012 06:48 PM
how stupid of me - I have just realised the screen is set to be the size of the image (i might have mentioned before) rather than 1024, I suspect this makes a difference?
10-31-2012 06:52 PM
Everything makes a difference here -)
From your code it is obvious that one received byte represents one pixel. Think whether it is right. If it is then think carefully how to 'split' this byte into four bytes because on PlayBook screen every pixel is represented by four bytes.
10-31-2012 07:31 PM
I'm trying to get my head around what you said BGmot, so im reading w*h*3 amount bytes but maybe I should be reading w*h*3 * 4 amount of bytes?
The thing is I initialise an array in java with w*h*3 size also so is this wrong size to hold my rgb bytes?
I'll keep going but I don't fully understand my problem still.
11-01-2012 12:14 AM
This thread is really confusing. Lets see if I understand this correctly...
* you have a JAVA server that gets an int using getARGB()
* I'm guessing you are writing this using DataOutputStream.writeInt
* you want to read in the int (which would be converted to 4 bytes each) and write it to a local buffer to apply to the screen
Did you set the pixel format for your screen to support ARGB or whatever RGB format you're using?
int format = SCREEN_FORMAT_RGB565 screen_set_pixmap_property_iv(screen_pix, SCREEN_PROPERTY_FORMAT, &format);
Not sure why you guys are trying to convert to integers... but here is code to convert 4 bytes to int:
11-01-2012 08:03 AM
Right, at first (yesterday morning) I was trying to write changes in an image (int) over network which I got from getARGB(int, ....) but then I switched to getARGB565(byte, ....) because I seen it returns a byte which is what I wanted to send over the network.
However I've realised that getARGB(int, ....) returns 16 bit color whereas I'm thinking I need 32bit color going off the advice of BGmot yesterday. So I'm back to getARGB(int, ....) as it returns 32 bit and now I'm converting this int to byte in java then sending the changes as byte.
The color of the 50x50 nblock image when I see it on top of the pb img seems similar(black, white, grey) with the color of the screen the server is screenshotting now because of this switch back to getARGB(int, ....) but still doesn't show properly, for a start the width and height of this image should be both 50 but it's displaying on the img at about width 50, height 200 when it should be 50 50.
nBytesPerPixel is 8 - I posted 4 yesterday but I had 1024 as width of screen in the calculation but really screen width is set to img.w so its about 640.
I thought I'd ask a couple of questions to see if I can figure this out - what makes BGmot say one received byte represents one pixel - where is this set in the first place?
Should I do the change from int to byte in java before sending or in c++? If c++ do I need to convert every single int in the image to little endian as thats what I've done to read an int from java to c++ in other area of app?
I've looked into the format and tried changing it to all kinds of different values to do with RGB and also for the image as well but same issue - which is currently that the 50x50 image is really 50x250 and it just seems to show solid colors which really doesn't seem to be an image of the top left of the screenshot from java.
I also noticed I was initialising my arrays w x h x 3 java and c++ without much questioning - is this correct?
Any help appreciated I know there's been a lot already. Please be assured as soon as I solve this I will post so nobody wastes their time on it.
11-01-2012 08:33 AM
I have posted my simple java code in the java forum to ensure no problems java side in case anybody wants to have a look.
11-01-2012 09:12 AM
bit2.getARGB(pixels, 0, width, 0, 0, w, h); byte pixels2 = integersToBytes(pixels); dout.writeInt(pixels2.length); out.write(pixels2);
Ok, let stick with getARGB as this function seems more appropriate. How do you send it over the socket? is it dout.writeInt ? our out.write?