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 Device: 9900
My Carrier: myself
Accepted Solution

does img_t have setARGB equivalent

I am sending and displaying a continous stream of image data using socket and img libriaries, the server has the potential to analyze and send back data containing just the changes in the images so I'm thinking it's more efficient to use this and just send the changes data.

 

However, once I have the changes data on the other end of socket (playbook) I so not see a way to insert this data using something similar to setARGB which allows the setting of areas in an image rather than the whole image.

 

Any suggestions on how to do this?

 

I'm also looking to find an already defined way of doing this kind of thing (transporting just the changes of an image over the network) if anybody knows anything that might be of interest to me.

 

Thank you.

 

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

Re: does img_t have setARGB equivalent

I can't seem to find anyway whatsoever to only update a rectangle area of an img_t, am I asking too much of the api as it is currently or is there actually another way to accomplish this?

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

Re: does img_t have setARGB equivalent

You have raw image date (array of bytes), what stops you from updating any region of this image?

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

Re: does img_t have setARGB equivalent

[ Edited ]

thank you for replying,

 

I am using img_load to load an array of bytes to my img object which is linked to screen pointer property, I'm pretty certain img_load will fail if array is not a proper image.

 

Is there an alternative (or a function im missing)to this to show the bytes onto the screen also giving me more low level control of the area painted? (please say yes!).

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

Re: does img_t have setARGB equivalent

I'm trying to read RGB data from java to c++, this data comes in an int array, I use DataOutputStream to write each int in the array when there is a difference in images at points (0,0, 50, 50), just testing for now but server seems ok.

 

A question that arises for me c++ side is do I need to convert these ints I read to little endian as I have been doing when reading an int for the size of the image or should I disregard ntohl() for this particular data?

 

I have posted my attempt below in case anybody can spot an obvious problem, it currently just reads the data. I have posted this question on a freelancer site as I can't keep asking experts to give their time for free but its difficult to get bb experts to answer on there so pm me if you want me to pay for your time - $100?

 

int w = 50;
		int h = 50;
		int toRead = w*h*3;
		int pixels[toRead];
		int offsetX = 0;
		int offsetY = 0;
		int readInt;
		while(connected)
		{

			for(int i = 0; i < toRead; i++)
			{

				readInt = readImageInt(imagesock, buf2, sizeof(buf2));//readImageInt reads 4 bytes and converts to little endian using ntohl
				pixels[i] = readInt;
				memcpy(img.access.direct.data, pixels, 0);

			}


		}

 

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

Re: does img_t have setARGB equivalent

What's buf2? I don't see it defined.

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

Re: does img_t have setARGB equivalent

sorry BGmot 

 

char buf2[4];

 

 

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

Re: does img_t have setARGB equivalent

making it more difficult to help me here aren't I - buf2 is actually irrelevent. 

 

int
readImageInt(int fd, char *buffer, size_t n)
{
	
	int nb, i;
	union {
		long int whole;
		char bytes[4];
	} v;
	memset(v.bytes, 0x00, 4);
	nb = recv(imagesock, v.bytes, 4, MSG_WAITALL);
	if (nb != 4)
		printf("Error: recv returned: %d\n", nb);
	v.whole = ntohl(v.whole);

	printf("readimagex %i ", v.whole);
	fflush(stdout);
	return v.whole;

}

 

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

Re: does img_t have setARGB equivalent

Can you explain why you need int?

It all depends on your sever/client, you send data byte by byte and you receive data byte by byte.... Sorry, I am lost -)

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

Re: does img_t have setARGB equivalent

ok, well the java server (bb phone) has 

 

public native void getARGB(int[] argbData, int offset, int scanLength, int x, int y, int width, int height);

 

which gives me data from certain part of image in int array, then I want to send this data over the socket and it seems DataOutputStream has writeint() which I am looping through my array and using to write each int.

 

Is there a better way that I couldn't see?

 

 

Please use plain text.