Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
bbdev12345
Posts: 117
Registered: ‎09-06-2011
My Carrier: myself

Re: does img_t have setARGB equivalent

BGmot, every time you ask a question you point me to the answer!

 

I assume I should be using getRGB565() which gives me back bytes and then I send/receive these bytes preceded by  maybe the size and coordinates of the change. For now I am just sticking with (0,0, 50, 50) until I see that area of the screen change on the playbook.

 

Could you tell me if memset(img.access.direct.data) was the right way to go to change a certain part of the image but with bytes?

Please use plain text.
Developer
BGmot
Posts: 1,061
Registered: ‎11-24-2011
My Carrier: x

Re: does img_t have setARGB equivalent

>Could you tell me if memset(img.access.direct.data) was the right way to go to change a certain part of the image but with bytes?

I don't see memset in your code -)

Probably post the code you have right now?

Please use plain text.
Trusted Contributor
bbdev12345
Posts: 117
Registered: ‎09-06-2011
My Carrier: myself

Re: does img_t have setARGB equivalent

sorry, I meant memcpy. I'm currently just changing the code to read char rather than int .

 

My main confusion as always been once I get the bytes/data what is the appropriate code to update only a certain part of the img with the data and coordinates. Would memcpy do this for me?

Please use plain text.
Developer
BGmot
Posts: 1,061
Registered: ‎11-24-2011
My Carrier: x

Re: does img_t have setARGB equivalent

I am pretty sure it will.

Please use plain text.
Trusted Contributor
bbdev12345
Posts: 117
Registered: ‎09-06-2011
My Carrier: myself

Re: does img_t have setARGB equivalent

I wish it was that simple!

 

The data is sent correctly when a change in the top left of the screen occurs and I see the data amount being read 7500 and then that amount of data is read correctly and no errors are occuring.

 

I just don't see anything changing on the first image that is read and displayed. My code loop which reads the changes after reading the first image is below..

 

int w = 50;
		int h = 50;
		int toRead = w*h*3;
		int pixels[toRead];
		int offsetX = 0;
		int offsetY = 0;
		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();
			memcpy(img.access.direct.data, image_data, 0);
			screen_post_window(screen, bg_buf, 1, rect, 0 );
			screen_flush_context(screencontext,0);



		}

 

Please use plain text.
Developer
BGmot
Posts: 1,061
Registered: ‎11-24-2011
My Carrier: x

Re: does img_t have setARGB equivalent

try replacing

memcpy(img.access.direct.data, image_data, 0);

with

memcpy(img.access.direct.data, image_data, toRead);

I don't think it will show you correct image but it should at least screw your image.

Please use plain text.
Trusted Contributor
bbdev12345
Posts: 117
Registered: ‎09-06-2011
My Carrier: myself

Re: does img_t have setARGB equivalent

There is a clue!

 

With toRead as an argument there is a fine line of something visual at the very top of the image. I am setting my screen position size and postion to size of image using code below (so I can see qt controls) before the read changes loop but I can't see how this makes a diffference.

 

int xpos = (1024 - img.w)/2;
	int ypos = (600 - img.h)/2;
	viewport_pos[0] = xpos;//-100;
	viewport_pos[1] = ypos;
	viewport_size[0] = img.w;
	viewport_size[1] = img.h;
	screen_set_window_property_iv(screen, SCREEN_PROPERTY_POSITION , viewport_pos);
	screen_set_window_property_iv(screen, SCREEN_PROPERTY_SIZE , viewport_size);
	screen_set_window_property_iv(screen, SCREEN_PROPERTY_SOURCE_SIZE , viewport_size);

 

Please use plain text.
Trusted Contributor
bbdev12345
Posts: 117
Registered: ‎09-06-2011
My Carrier: myself

Re: does img_t have setARGB equivalent

Also if I use memcpy(img.access.direct.data, image_data, 50); then the fine line that appears is what I would guess is only 50px wide starting at 0,0

 

and

 

if I have memcpy(img.access.direct.data, image_data, toRead); then the line that appears is the width of the image starting at 0,0.

 

Confused!

Please use plain text.
Developer
BGmot
Posts: 1,061
Registered: ‎11-24-2011
My Carrier: x

Re: does img_t have setARGB equivalent

Try to replace your memcpy with this:

for (int i=0; i < h; i++)
memcpy(img.access.direct.data+i*img.access.direct.stride, image_data, w);

 

 

Please use plain text.
Trusted Contributor
bbdev12345
Posts: 117
Registered: ‎09-06-2011
My Carrier: myself

Re: does img_t have setARGB equivalent

It seems memcpy(img.access.direct.data, image_data, toRead); is closer BGmot with regards to color but not height. The image should have white color and that code contains black and white in its thin line,

 

the code memcpy(img.access.direct.data+i*img.access.direct.stride, image_data, w); just contains pure black but does make it the correct height.

 

Tried numerous other things before replying also.

Please use plain text.