Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi Everybody,

I would like to create thumbnails for the following images:

1. jpeg/jpg : I found jpegBrew extension. I used it, but its quality is not good. Is there any way to make better quality output using jpegBrew? Or is there any other APIs.

2. bmp: How can I resize/scale bmp images?

3. png: How can I resize / scale png images?

Pls help about examples, tips, ideas.
I need it urgent.

Thanks
Tonmoy

tonmoy80 wrote:Hi Everybody,
I would like to create thumbnails for the following images:
1. jpeg/jpg : I found jpegBrew extension. I used it, but its quality is not good. Is there any way to make better quality output using jpegBrew? Or is there any other APIs.
2. bmp: How can I resize/scale bmp images?
3. png: How can I resize / scale png images?
Pls help about examples, tips, ideas.
I need it urgent.
Thanks
Tonmoy
jpegBREW uses a quick and dirty scale routine. One way to improve
the quality of any jpeg it renders is to give it a palette (see documentation)
rather than have it figure out the palette for you. Also, make sure you
are requesting high quality output as jpegBREW also has a lower
quality out put (IJPEGBREW_GetDIBFromJpeg fourth parameter should be
set to TRUE for high quality output).
What are your scaling start and end sizes?
If you want a very high quality scaling routine then you will need to implment
a filter that looks at neighboring pixels. And you will want to give
additional consideration to the specific palette of the device you are working
with. You would want to start with 32 bit color if possible for this so that
you can gather as much color information as possible before scaling.
There are many algorithms out there, some work better than others.
This will be time and memory intensive.

tonmoy80 wrote:Hi Everybody,
I would like to create thumbnails for the following images:
1. jpeg/jpg : I found jpegBrew extension. I used it, but its quality is not good. Is there any way to make better quality output using jpegBrew? Or is there any other APIs.
2. bmp: How can I resize/scale bmp images?
3. png: How can I resize / scale png images?
Pls help about examples, tips, ideas.
I need it urgent.
Thanks
Tonmoy
jpegBREW uses a quick and dirty scale routine. One way to improve
the quality of any jpeg it renders is to give it a palette (see documentation)
rather than have it figure out the palette for you. Also, make sure you
are requesting high quality output as jpegBREW also has a lower
quality out put (IJPEGBREW_GetDIBFromJpeg fourth parameter should be
set to TRUE for high quality output).
What are your scaling start and end sizes?
If you want a very high quality scaling routine then you will need to implment
a filter that looks at neighboring pixels. And you will want to give
additional consideration to the specific palette of the device you are working
with. You would want to start with 32 bit color if possible for this so that
you can gather as much color information as possible before scaling.
There are many algorithms out there, some work better than others.
This will be time and memory intensive.

Hi jmiller2,
Thanks for your reply.
Issue-1: high quality output
------------------------------------
I used palette. my palette image and original image (that will be scaled) is same.
secondly, the 4th parameter of IJPEGBREW_GetDIBFromJpeg() is set as TRUE.
But I did not get high quality image. my scalling start and end size is based on device size (128 x 160).
Issue-2: Dynamically image loading
-------------------------------------------------
I found a sample test code to use jpegBrew in the forum which loads images from
resource file. But I need to load the image dynamically. Is it possible to
load image dynamically and use the image in jpegBREW?
Issue-3: About BMP and PNG
--------------------------------------
I did not get any answer about bmp and png format resize/scaling.
Thanks again....
Tonmoy

Hi jmiller2,
Thanks for your reply.
Issue-1: high quality output
------------------------------------
I used palette. my palette image and original image (that will be scaled) is same.
secondly, the 4th parameter of IJPEGBREW_GetDIBFromJpeg() is set as TRUE.
But I did not get high quality image. my scalling start and end size is based on device size (128 x 160).
Issue-2: Dynamically image loading
-------------------------------------------------
I found a sample test code to use jpegBrew in the forum which loads images from
resource file. But I need to load the image dynamically. Is it possible to
load image dynamically and use the image in jpegBREW?
Issue-3: About BMP and PNG
--------------------------------------
I did not get any answer about bmp and png format resize/scaling.
Thanks again....
Tonmoy

tonmoy80 wrote:Hi jmiller2,
Thanks for your reply.
Issue-1: high quality output
------------------------------------
I used palette. my palette image and original image (that will be scaled) is same.
secondly, the 4th parameter of IJPEGBREW_GetDIBFromJpeg() is set as TRUE.
But I did not get high quality image. my scalling start and end size is based on device size (128 x 160).
Issue-2: Dynamically image loading
-------------------------------------------------
I found a sample test code to use jpegBrew in the forum which loads images from
resource file. But I need to load the image dynamically. Is it possible to
load image dynamically and use the image in jpegBREW?
Issue-3: About BMP and PNG
--------------------------------------
I did not get any answer about bmp and png format resize/scaling.
Thanks again....
Tonmoy
1. Yes but what is the start size? How much is it being scaled?
If you can post the image here it would be helpful. So I can see
exactly what the quality problem relates to. The larger the difference
between image and scaled result the more blurring there will be.
(or you can email the image and palette to me). Are you testing on a
device or the emulator? Sometimes the emulator does not reflect
the quality of the device with certain color depths.
2. Yes, you can load the jpeg from memory. Just pass the pointer
to the jpeg buffer as the second parameter to IJPEGBREW_GetDIBFromJpeg.
3. All scaling routines need raw data. If you are going to use your
own scaling routine you will need to get at the raw bmp data.
(So if it is png then you will have to decode it to bmp first)

tonmoy80 wrote:Hi jmiller2,
Thanks for your reply.
Issue-1: high quality output
------------------------------------
I used palette. my palette image and original image (that will be scaled) is same.
secondly, the 4th parameter of IJPEGBREW_GetDIBFromJpeg() is set as TRUE.
But I did not get high quality image. my scalling start and end size is based on device size (128 x 160).
Issue-2: Dynamically image loading
-------------------------------------------------
I found a sample test code to use jpegBrew in the forum which loads images from
resource file. But I need to load the image dynamically. Is it possible to
load image dynamically and use the image in jpegBREW?
Issue-3: About BMP and PNG
--------------------------------------
I did not get any answer about bmp and png format resize/scaling.
Thanks again....
Tonmoy
1. Yes but what is the start size? How much is it being scaled?
If you can post the image here it would be helpful. So I can see
exactly what the quality problem relates to. The larger the difference
between image and scaled result the more blurring there will be.
(or you can email the image and palette to me). Are you testing on a
device or the emulator? Sometimes the emulator does not reflect
the quality of the device with certain color depths.
2. Yes, you can load the jpeg from memory. Just pass the pointer
to the jpeg buffer as the second parameter to IJPEGBREW_GetDIBFromJpeg.
3. All scaling routines need raw data. If you are going to use your
own scaling routine you will need to get at the raw bmp data.
(So if it is png then you will have to decode it to bmp first)

jmiller2 wrote:1. Yes but what is the start size? How much is it being scaled?
If you can post the image here it would be helpful. So I can see
exactly what the quality problem relates to. The larger the difference
between image and scaled result the more blurring there will be.
(or you can email the image and palette to me). Are you testing on a
device or the emulator? Sometimes the emulator does not reflect
the quality of the device with certain color depths.
2. Yes, you can load the jpeg from memory. Just pass the pointer
to the jpeg buffer as the second parameter to IJPEGBREW_GetDIBFromJpeg.
3. All scaling routines need raw data. If you are going to use your
own scaling routine you will need to get at the raw bmp data.
(So if it is png then you will have to decode it to bmp first)
BREW has scaling routines for various situations and there are
many discussions about this in the forum archive. However, there
are limitations on these based on the individual device capabilities.

jmiller2 wrote:1. Yes but what is the start size? How much is it being scaled?
If you can post the image here it would be helpful. So I can see
exactly what the quality problem relates to. The larger the difference
between image and scaled result the more blurring there will be.
(or you can email the image and palette to me). Are you testing on a
device or the emulator? Sometimes the emulator does not reflect
the quality of the device with certain color depths.
2. Yes, you can load the jpeg from memory. Just pass the pointer
to the jpeg buffer as the second parameter to IJPEGBREW_GetDIBFromJpeg.
3. All scaling routines need raw data. If you are going to use your
own scaling routine you will need to get at the raw bmp data.
(So if it is png then you will have to decode it to bmp first)
BREW has scaling routines for various situations and there are
many discussions about this in the forum archive. However, there
are limitations on these based on the individual device capabilities.

Hi jmiller2,
Thanks for your helping information.
1. High qaulity output and program crash
==============================
I could not understand about your start size.
But, the IJPEGBREW_GetDIBFromJpeg() method scaled the image with the following value (according to jpegTest program found in the forum)
IJPEGBREW_GetDIBFromJpeg(pMe->m_pIJpegBREW, pDataStart, pMe->m_iFileSize, TRUE, TRUE, JpegCallback, pMe, pMe->m_pMyBuffer,pMe->m_cxWidth, pMe->m_cyHeight);
pMe->m_cxWidth = 128, pMe->m_cyHeight = 160, pMe->m_iFileSize = 5756.
I would like to scale it as thumbnail (width 26 X height 24).
With the value of 128 and 160, it scaled successfully. although image quality is not
so good. But if I want to scale it much smaller like 1/4, 1/6, the program crash.
I send you my original and palette image by e-mail. do you have the jpegTest program that I found on the forum?
Thanks
Tonmoy

Hi jmiller2,
Thanks for your helping information.
1. High qaulity output and program crash
==============================
I could not understand about your start size.
But, the IJPEGBREW_GetDIBFromJpeg() method scaled the image with the following value (according to jpegTest program found in the forum)
IJPEGBREW_GetDIBFromJpeg(pMe->m_pIJpegBREW, pDataStart, pMe->m_iFileSize, TRUE, TRUE, JpegCallback, pMe, pMe->m_pMyBuffer,pMe->m_cxWidth, pMe->m_cyHeight);
pMe->m_cxWidth = 128, pMe->m_cyHeight = 160, pMe->m_iFileSize = 5756.
I would like to scale it as thumbnail (width 26 X height 24).
With the value of 128 and 160, it scaled successfully. although image quality is not
so good. But if I want to scale it much smaller like 1/4, 1/6, the program crash.
I send you my original and palette image by e-mail. do you have the jpegTest program that I found on the forum?
Thanks
Tonmoy

tonmoy80 wrote:Hi jmiller2,
Thanks for your helping information.
1. High qaulity output and program crash
==============================
I could not understand about your start size.
But, the IJPEGBREW_GetDIBFromJpeg() method scaled the image with the following value (according to jpegTest program found in the forum)
IJPEGBREW_GetDIBFromJpeg(pMe->m_pIJpegBREW, pDataStart, pMe->m_iFileSize, TRUE, TRUE, JpegCallback, pMe, pMe->m_pMyBuffer,pMe->m_cxWidth, pMe->m_cyHeight);
pMe->m_cxWidth = 128, pMe->m_cyHeight = 160, pMe->m_iFileSize = 5756.
I would like to scale it as thumbnail (width 26 X height 24).
With the value of 128 and 160, it scaled successfully. although image quality is not
so good. But if I want to scale it much smaller like 1/4, 1/6, the program crash.
I send you my original and palette image by e-mail. do you have the jpegTest program that I found on the forum?
Thanks
Tonmoy
Hi Tonmoy,
I am also replying to your email with some images.
I think the quality problem you are seeing is more an
artifact of converting to an 8-bit image than an issue with
the resizing. If you do the resizing using photoshop or fireworks
you will see that initially the image looks a little bit better, but once
you save it our to an 8 bit bmp or gif file the same quality shows up
as what jpegBREW produces.
As far as the crash, I found a rounding bug that will cause some
problems with scaling smaller. I've fixed the bug and have a new version
of jpegBREW which I will be submitting to NSTL after I get back from
GDC. Meanwhile, anyone who needs to fix to keep working I can
email it to you after I have a few more hours to run it through QA.
In your specific case, you can work around it by changing your starting
image to 228 by 152. I did this for you and sent you the image.
---jeff

tonmoy80 wrote:Hi jmiller2,
Thanks for your helping information.
1. High qaulity output and program crash
==============================
I could not understand about your start size.
But, the IJPEGBREW_GetDIBFromJpeg() method scaled the image with the following value (according to jpegTest program found in the forum)
IJPEGBREW_GetDIBFromJpeg(pMe->m_pIJpegBREW, pDataStart, pMe->m_iFileSize, TRUE, TRUE, JpegCallback, pMe, pMe->m_pMyBuffer,pMe->m_cxWidth, pMe->m_cyHeight);
pMe->m_cxWidth = 128, pMe->m_cyHeight = 160, pMe->m_iFileSize = 5756.
I would like to scale it as thumbnail (width 26 X height 24).
With the value of 128 and 160, it scaled successfully. although image quality is not
so good. But if I want to scale it much smaller like 1/4, 1/6, the program crash.
I send you my original and palette image by e-mail. do you have the jpegTest program that I found on the forum?
Thanks
Tonmoy
Hi Tonmoy,
I am also replying to your email with some images.
I think the quality problem you are seeing is more an
artifact of converting to an 8-bit image than an issue with
the resizing. If you do the resizing using photoshop or fireworks
you will see that initially the image looks a little bit better, but once
you save it our to an 8 bit bmp or gif file the same quality shows up
as what jpegBREW produces.
As far as the crash, I found a rounding bug that will cause some
problems with scaling smaller. I've fixed the bug and have a new version
of jpegBREW which I will be submitting to NSTL after I get back from
GDC. Meanwhile, anyone who needs to fix to keep working I can
email it to you after I have a few more hours to run it through QA.
In your specific case, you can work around it by changing your starting
image to 228 by 152. I did this for you and sent you the image.
---jeff

Hi Jeff,
Thanks again for continuous response to me.
Waiting for your bug-fixed code of jpegBREW.
1. About Crash
---------------------
According to your suggestion, I used your image.
So, now your pallete image size = 227 x 149 and
your original image size = 228 x 152 and used the following code:
IJPEGBREW_GetDIBFromJpeg(pMe->m_pIJpegBREW, pDataStart, pMe->m_iFileSize, TRUE, TRUE, JpegCallback, pMe, pMe->m_pMyBuffer,pMe->m_cxWidth/4, pMe->m_cyHeight/4);
where pMe->m_cxWidth = 128 and pMe->m_cxHeight = 160. (screen size)
But the program crashed, considering that there is rounding problem in jpegBREW.
Thanks
Tonmoy

Hi Jeff,
Thanks again for continuous response to me.
Waiting for your bug-fixed code of jpegBREW.
1. About Crash
---------------------
According to your suggestion, I used your image.
So, now your pallete image size = 227 x 149 and
your original image size = 228 x 152 and used the following code:
IJPEGBREW_GetDIBFromJpeg(pMe->m_pIJpegBREW, pDataStart, pMe->m_iFileSize, TRUE, TRUE, JpegCallback, pMe, pMe->m_pMyBuffer,pMe->m_cxWidth/4, pMe->m_cyHeight/4);
where pMe->m_cxWidth = 128 and pMe->m_cxHeight = 160. (screen size)
But the program crashed, considering that there is rounding problem in jpegBREW.
Thanks
Tonmoy

Hi Jeff,
Here is another issue of jpegBREW.
Size/Length of the scaled image
-----------------------------------------
After scaling the image using jpegBREW, how can I get the length/size of the
scaled image? For example, orginal image size = 5756 bytes, after scaling by
1/2, 1/4 etc. how can I get the size of the final image?
Thanks
Tonmoy

Hi Jeff,
Here is another issue of jpegBREW.
Size/Length of the scaled image
-----------------------------------------
After scaling the image using jpegBREW, how can I get the length/size of the
scaled image? For example, orginal image size = 5756 bytes, after scaling by
1/2, 1/4 etc. how can I get the size of the final image?
Thanks
Tonmoy

tonmoy80 wrote:Hi Jeff,
Here is another issue of jpegBREW.
Size/Length of the scaled image
-----------------------------------------
After scaling the image using jpegBREW, how can I get the length/size of the
scaled image? For example, orginal image size = 5756 bytes, after scaling by
1/2, 1/4 etc. how can I get the size of the final image?
Thanks
Tonmoy
Size of raw BMP image will be the same as any other DIB BMP, or
((Width + PAD) * Height) + BITMAPHEADERSIZE .
PAD = width padded to 4 bytes.
---jeff

tonmoy80 wrote:Hi Jeff,
Here is another issue of jpegBREW.
Size/Length of the scaled image
-----------------------------------------
After scaling the image using jpegBREW, how can I get the length/size of the
scaled image? For example, orginal image size = 5756 bytes, after scaling by
1/2, 1/4 etc. how can I get the size of the final image?
Thanks
Tonmoy
Size of raw BMP image will be the same as any other DIB BMP, or
((Width + PAD) * Height) + BITMAPHEADERSIZE .
PAD = width padded to 4 bytes.
---jeff

Hi Jeff,
Thanks for your answer.
Here is aonther issue of jpefBrew.
About conversion of raw image to IImage
-----------------------------------------------------
As using jpegBrew, we get scaled image which is stored in char* variable.
Then using CONVERTBMP we get native bitmap stored in void* variable.
But I want to convert the image into IImage. So, there are two types of
conversion:
1. char* to IImage
2. void* to IImage
How can I do that?
Thanks again.....
Tonmoy

Hi Jeff,
Thanks for your answer.
Here is aonther issue of jpefBrew.
About conversion of raw image to IImage
-----------------------------------------------------
As using jpegBrew, we get scaled image which is stored in char* variable.
Then using CONVERTBMP we get native bitmap stored in void* variable.
But I want to convert the image into IImage. So, there are two types of
conversion:
1. char* to IImage
2. void* to IImage
How can I do that?
Thanks again.....
Tonmoy

Hi Jeff,
about scaled size
-----------------------
Quote:Size of raw BMP image will be the same as any other DIB BMP
Did you mean that before scaling and after scaling file size is same?
I need the size bcs I want to transform scaled image into IImage to show it in IMenuCtl.
I can transform the raw image into IImage. But the scaled image can not be done.
may be there is the problem of converted size.
Moreover, I could not understand about PAD and BITMAPHEADERSIZE.
Thanks
Tonmoy

Hi Jeff,
about scaled size
-----------------------
Quote:Size of raw BMP image will be the same as any other DIB BMP
Did you mean that before scaling and after scaling file size is same?
I need the size bcs I want to transform scaled image into IImage to show it in IMenuCtl.
I can transform the raw image into IImage. But the scaled image can not be done.
may be there is the problem of converted size.
Moreover, I could not understand about PAD and BITMAPHEADERSIZE.
Thanks
Tonmoy

tonmoy80 wrote:Hi Jeff,
Thanks for your answer.
Here is aonther issue of jpefBrew.
About conversion of raw image to IImage
-----------------------------------------------------
As using jpegBrew, we get scaled image which is stored in char* variable.
Then using CONVERTBMP we get native bitmap stored in void* variable.
But I want to convert the image into IImage. So, there are two types of
conversion:
1. char* to IImage
2. void* to IImage
How can I do that?
Thanks again.....
Tonmoy
Why do you want to use IImage?

tonmoy80 wrote:Hi Jeff,
Thanks for your answer.
Here is aonther issue of jpefBrew.
About conversion of raw image to IImage
-----------------------------------------------------
As using jpegBrew, we get scaled image which is stored in char* variable.
Then using CONVERTBMP we get native bitmap stored in void* variable.
But I want to convert the image into IImage. So, there are two types of
conversion:
1. char* to IImage
2. void* to IImage
How can I do that?
Thanks again.....
Tonmoy
Why do you want to use IImage?

tonmoy80 wrote:
about scaled size
-----------------------
Did you mean that before scaling and after scaling file size is same?
I need the size bcs I want to transform scaled image into IImage to show it in IMenuCtl.
Moreover, I could not understand about PAD and BITMAPHEADERSIZE.
No. Its the same as a DIB of the newly scaled size. Which is equal to
the bitmap header plus the width+pad times the height. The pad is to
pad out to 4 bytes. So 19 width by 20 height bitmap would be
BITMAPHEADERSIZE + ((19 + 1 pad) * 20) = 1478 bytes.
This is useful if you want to write out the buffer to a BMP file.
Remeber, though, that the buffer used is the original one you
passed in. You have to be careful about fragmentation if you are
going to pass this buffer to another routine.
tonmoy80 wrote:
I can transform the raw image into IImage. But the scaled image can not be done.
may be there is the problem of converted size.
Not sure why you want to use IImage here. You already have a
blittable image after you call CONVERTBMP.

tonmoy80 wrote:
about scaled size
-----------------------
Did you mean that before scaling and after scaling file size is same?
I need the size bcs I want to transform scaled image into IImage to show it in IMenuCtl.
Moreover, I could not understand about PAD and BITMAPHEADERSIZE.
No. Its the same as a DIB of the newly scaled size. Which is equal to
the bitmap header plus the width+pad times the height. The pad is to
pad out to 4 bytes. So 19 width by 20 height bitmap would be
BITMAPHEADERSIZE + ((19 + 1 pad) * 20) = 1478 bytes.
This is useful if you want to write out the buffer to a BMP file.
Remeber, though, that the buffer used is the original one you
passed in. You have to be careful about fragmentation if you are
going to pass this buffer to another routine.
tonmoy80 wrote:
I can transform the raw image into IImage. But the scaled image can not be done.
may be there is the problem of converted size.
Not sure why you want to use IImage here. You already have a
blittable image after you call CONVERTBMP.

Hi Jeff,
Actually, I wanted to use the converted image in IMenuCtl. IMenuCtl uses IImage.
But jpegBrew gives me converted raw image. that is why I needed the size to display it IMenuCtl.
Anyway, this problem is solved. Thanks a lot for your advise........
I am waiting for your bug fixed code (rounding problem) of jpegBREW.
Tonmoy

Hi Jeff,
Actually, I wanted to use the converted image in IMenuCtl. IMenuCtl uses IImage.
But jpegBrew gives me converted raw image. that is why I needed the size to display it IMenuCtl.
Anyway, this problem is solved. Thanks a lot for your advise........
I am waiting for your bug fixed code (rounding problem) of jpegBREW.
Tonmoy

about bmp and png scaling
-----------------------------------
You said to use raw data for scaling bmp (if I have my own routine)
and for png, at first to decode it to bmp in your early posts.
Actually as the time is short, it will take time to design own routine.
But is there any support in brew 3.0 for bmp/png scaling? Or any extension, source codes, useful links for bmp/png scaling?
Pls help.... I need it urgent...
Thanks
Tonmoy

about bmp and png scaling
-----------------------------------
You said to use raw data for scaling bmp (if I have my own routine)
and for png, at first to decode it to bmp in your early posts.
Actually as the time is short, it will take time to design own routine.
But is there any support in brew 3.0 for bmp/png scaling? Or any extension, source codes, useful links for bmp/png scaling?
Pls help.... I need it urgent...
Thanks
Tonmoy

tonmoy80 wrote:about bmp and png scaling
-----------------------------------
You said to use raw data for scaling bmp (if I have my own routine)
and for png, at first to decode it to bmp in your early posts.
Actually as the time is short, it will take time to design own routine.
But is there any support in brew 3.0 for bmp/png scaling? Or any extension, source codes, useful links for bmp/png scaling?
Pls help.... I need it urgent...
Thanks
Tonmoy
I have extension code for gif/animated gif decoding with bmp scaling.
I haven't created a png decoder myself, most of the 2.x handsets
support png natively, although they would also have to support BREW's
native scaling routines to be useful to you (Itranform or stretchblt).
IME it seems better to have an independant set of code to
do this rather than rely on the OEM to have implemented it
correctly (and have it bite you later on).
If you want you can contact me directly about creating PNG or BMP scaling
code for you that would work across all handsets.
---jeff

tonmoy80 wrote:about bmp and png scaling
-----------------------------------
You said to use raw data for scaling bmp (if I have my own routine)
and for png, at first to decode it to bmp in your early posts.
Actually as the time is short, it will take time to design own routine.
But is there any support in brew 3.0 for bmp/png scaling? Or any extension, source codes, useful links for bmp/png scaling?
Pls help.... I need it urgent...
Thanks
Tonmoy
I have extension code for gif/animated gif decoding with bmp scaling.
I haven't created a png decoder myself, most of the 2.x handsets
support png natively, although they would also have to support BREW's
native scaling routines to be useful to you (Itranform or stretchblt).
IME it seems better to have an independant set of code to
do this rather than rely on the OEM to have implemented it
correctly (and have it bite you later on).
If you want you can contact me directly about creating PNG or BMP scaling
code for you that would work across all handsets.
---jeff