how can I capture a .png image | developer.brewmp.com how can I capture a .png image | developer.brewmp.com

Developer

how can I capture a .png image

Forums:

Hi all,
I want to Capture a .png image. I can successfully capture .bmp image through below stated code. Can any body help what changes are required to capture .png image.

{
BMP_FILE_HEADER bmpfile;
uint32 *psaveplatte;
IBitmap *pIBitmap=NULL;
RGBCOLOR test;
AEEPoint pPoint;
NATIVE_COLOR native;
int i=0;
int j=0;;
uint8 nocolors=0;
byte *temp;
byte *pdata;

bmpfile.reserved=0;
bmpfile.header_size=40;
bmpfile.width=176;
bmpfile.height=205;
bmpfile.planes = 1;
bmpfile.bits_per_pixel = 8;
bmpfile.compression=0;
bmpfile.bitmap_size=0;
bmpfile.horizontal_resolution=0;
bmpfile.vertical_resolution=0;

IDISPLAY_GetDeviceBitmap(GET_IDISPLAY(),&pIBitmap);
psaveplatte=(uint32 *)MALLOC(256*sizeof(uint32));
pdata=(byte*)MALLOC(176*205);
temp=pdata;

for(i=204;i>=0;i--) // One can rotate the image in all four directions by changing
for(j=0;j<176;j++) // 1. i=0 to i<205; 2. j=175 to j>=0; 3. 1 and j=0 to j<176;
{ // 4. The above one which isin normal position....
pPoint.x=j;
pPoint.y=i;
IBITMAP_GetPixel(pIBitmap,j,i,(uint32 *)&native.color);
test.a[0]=FIVEBIT_8BIT(native.stct.B);
test.a[1]=SIXBIT_8BIT(native.stct.G);
test.a[2]=FIVEBIT_8BIT(native.stct.R);
test.a[3]=0;

{
int k=0;
for(;k

You need to write your own PNG file to save the image in png format.

You need to write your own PNG file to save the image in png format.

But how ? pls post the code...

But how ? pls post the code...

Go to
http://libpng.org/ and download pnglib source code and check then you will know how to write png files....

Go to
http://libpng.org/ and download pnglib source code and check then you will know how to write png files....

depending on whether the target has PNG encoding support, you can use IMEDIAUTIL_EncodeMedia to encode to PNG..
If the target does not have support for PNG encoding, then it will fail..In this case, you need to write your own PNG encoder..

depending on whether the target has PNG encoding support, you can use IMEDIAUTIL_EncodeMedia to encode to PNG..
If the target does not have support for PNG encoding, then it will fail..In this case, you need to write your own PNG encoder..

I think my query is misunderstood. Actully if I load a .PNG image in BRI and try to capture it ,I got a disturbed image and colors are not proper.

I think my query is misunderstood. Actully if I load a .PNG image in BRI and try to capture it ,I got a disturbed image and colors are not proper.

can u please explain your requirement a bit more...

can u please explain your requirement a bit more...

can you explain the whole procedure you are doing......form saving a png.....loading to Bri...to displaying it on device...

can you explain the whole procedure you are doing......form saving a png.....loading to Bri...to displaying it on device...

1. In my BRI all the images are in png format.
2. I want to capture the image through above stated code but colors of saved image are not proper. If I load BMP images in BRI , It works properly.

1. In my BRI all the images are in png format.
2. I want to capture the image through above stated code but colors of saved image are not proper. If I load BMP images in BRI , It works properly.

It really doesn't matter whether you are drawing a bmp/png/gif on the screen display, Once you draw the image on the screen, You are getting just the color component of each pixel. After that you are saving this pixel color component in another bitmap.
Post your whole code that you are using along with your bar file.

It really doesn't matter whether you are drawing a bmp/png/gif on the screen display, Once you draw the image on the screen, You are getting just the color component of each pixel. After that you are saving this pixel color component in another bitmap.
Post your whole code that you are using along with your bar file.

Code for capturing image is already mentioned above. I m drawing png image on screen and want to capture it

Code for capturing image is already mentioned above. I m drawing png image on screen and want to capture it

Once a image has been drawn on the screen display, how one can differ image format?????????
It's nothing to do with image format...I am the one who posted the code so I know the code better and how it work. So post what you are using...so that we can check where you are getting wrong..

Once a image has been drawn on the screen display, how one can differ image format?????????
It's nothing to do with image format...I am the one who posted the code so I know the code better and how it work. So post what you are using...so that we can check where you are getting wrong..

hi, I am calling this function after drawing .png image. The catured image saved to the path :-shared/picture/screenshot.bmp.
now the colors of this saved image is not proper (as the original image loaded in BRI has) .
void WelcomeCanvas::capturescreen()
{
BMP_FILE_HEADER bmpfile;
uint32 *psaveplatte;
IBitmap *pIBitmap=NULL;
RGBCOLOR test;
AEEPoint pPoint;
NATIVE_COLOR native;
int i=0;
int j=0;;
uint8 nocolors=0;
byte *temp;
byte *pdata;
bmpfile.reserved=0;
bmpfile.header_size=40;
bmpfile.width=128;
bmpfile.height=128;
bmpfile.planes = 1;
bmpfile.bits_per_pixel = 8;
bmpfile.compression=0;
bmpfile.bitmap_size=0;
bmpfile.horizontal_resolution=0;
bmpfile.vertical_resolution=0;
IDISPLAY_GetDeviceBitmap(GET_IDISPLAY(),&pIBitmap);
psaveplatte=(uint32 *)MALLOC(256*sizeof(uint32));
pdata=(byte*)MALLOC(128*129);
temp=pdata;
for(i=128;i>=0;i--) // One can rotate the image in all four directions by changing
for(j=0;j<128;j++) // 1. i=0 to i<205; 2. j=175 to j>=0; 3. 1 and j=0 to j<176;
{ // 4. The above one which isin normal position....
pPoint.x=j;
pPoint.y=i;
IBITMAP_GetPixel(pIBitmap,j,i,(uint32 *)&native.color);
test.a[0]=FIVEBIT_8BIT(native.stct.B);
test.a[1]=SIXBIT_8BIT(native.stct.G);
test.a[2]=FIVEBIT_8BIT(native.stct.R);
test.a[3]=0;
{
int k=0;
for(;k

hi, I am calling this function after drawing .png image. The catured image saved to the path :-shared/picture/screenshot.bmp.
now the colors of this saved image is not proper (as the original image loaded in BRI has) .
void WelcomeCanvas::capturescreen()
{
BMP_FILE_HEADER bmpfile;
uint32 *psaveplatte;
IBitmap *pIBitmap=NULL;
RGBCOLOR test;
AEEPoint pPoint;
NATIVE_COLOR native;
int i=0;
int j=0;;
uint8 nocolors=0;
byte *temp;
byte *pdata;
bmpfile.reserved=0;
bmpfile.header_size=40;
bmpfile.width=128;
bmpfile.height=128;
bmpfile.planes = 1;
bmpfile.bits_per_pixel = 8;
bmpfile.compression=0;
bmpfile.bitmap_size=0;
bmpfile.horizontal_resolution=0;
bmpfile.vertical_resolution=0;
IDISPLAY_GetDeviceBitmap(GET_IDISPLAY(),&pIBitmap);
psaveplatte=(uint32 *)MALLOC(256*sizeof(uint32));
pdata=(byte*)MALLOC(128*129);
temp=pdata;
for(i=128;i>=0;i--) // One can rotate the image in all four directions by changing
for(j=0;j<128;j++) // 1. i=0 to i<205; 2. j=175 to j>=0; 3. 1 and j=0 to j<176;
{ // 4. The above one which isin normal position....
pPoint.x=j;
pPoint.y=i;
IBITMAP_GetPixel(pIBitmap,j,i,(uint32 *)&native.color);
test.a[0]=FIVEBIT_8BIT(native.stct.B);
test.a[1]=SIXBIT_8BIT(native.stct.G);
test.a[2]=FIVEBIT_8BIT(native.stct.R);
test.a[3]=0;
{
int k=0;
for(;k

In the below code
Quote:
test.a[0]=FIVEBIT_8BIT(native.stct.B);
test.a[1]=SIXBIT_8BIT(native.stct.G);
test.a[2]=FIVEBIT_8BIT(native.stct.R);
Replace B with R and R with B as below
test.a[0]=FIVEBIT_8BIT(native.stct.R);
test.a[1]=SIXBIT_8BIT(native.stct.G);
test.a[2]=FIVEBIT_8BIT(native.stct.B);
your color union struct should look like below
typedef union _mynative
{
uint16 color;
struct{
uint16 R:5; // 31 - 255 == 0.122
uint16 G:6; // 63 - 255 == 0.248
uint16 B:5; // 31 - 255 == 0.122
stct;
mynative;

In the below code
Quote:
test.a[0]=FIVEBIT_8BIT(native.stct.B);
test.a[1]=SIXBIT_8BIT(native.stct.G);
test.a[2]=FIVEBIT_8BIT(native.stct.R);
Replace B with R and R with B as below
test.a[0]=FIVEBIT_8BIT(native.stct.R);
test.a[1]=SIXBIT_8BIT(native.stct.G);
test.a[2]=FIVEBIT_8BIT(native.stct.B);
your color union struct should look like below
typedef union _mynative
{
uint16 color;
struct{
uint16 R:5; // 31 - 255 == 0.122
uint16 G:6; // 63 - 255 == 0.248
uint16 B:5; // 31 - 255 == 0.122
stct;
mynative;

STILL NOT PROPER . Out of 176x204 only part 176x60(from top) is fine but remaining colors are not proper.

STILL NOT PROPER . Out of 176x204 only part 176x60(from top) is fine but remaining colors are not proper.

Hi, It is working fine on some images but not on all. I think if image has too many colors it is not working othewise it's fine

Hi, It is working fine on some images but not on all. I think if image has too many colors it is not working othewise it's fine

Can you post those images, original and saved--both images..
I don't have any issue till now, It only supports 8bit images.

Can you post those images, original and saved--both images..
I don't have any issue till now, It only supports 8bit images.

hi,
pls find these 2 images and their screenshots(saved images).

hi,
pls find these 2 images and their screenshots(saved images).

bwall1.png is saving fine. This image has 255 colors.
But front.png generate the same screen shot that you have attached..This is because the image has 256 colors.
In the code variable "nocolors" is defined as uint8, this causing a problem. So the code has some problem that has 256 colored images...
Resolution:
replace the following code
if(k==nocolors)
with
if(k==nocolors && k<256)
and
Define nocolors as uint16.

bwall1.png is saving fine. This image has 255 colors.
But front.png generate the same screen shot that you have attached..This is because the image has 256 colors.
In the code variable "nocolors" is defined as uint8, this causing a problem. So the code has some problem that has 256 colored images...
Resolution:
replace the following code
if(k==nocolors)
with
if(k==nocolors && k<256)
and
Define nocolors as uint16.

Problem solved.
Thanks for your co operation.

Problem solved.
Thanks for your co operation.