Page 1 of 2

Bitmap ARGB1555 image format

Posted: 2019-01-05T11:26:24-07:00
by Coder
Hi,

I am new to imagemagick and started using ImageMagic++ api for the image operations. So far its a great product, but I need help from you guys.
I need to create a bmp image with ARGB1555 (16 bit), since I need to pass pixels as ARGB1555 to hardware(and its support only this format).
I could not able to figure out the API for that. I could see in change list where its telling support for ARGB1555 as image subtype. I could not able to figure any APIs doing the same. Please share your suggestions

Re: Bitmap ARGB1555 image format

Posted: 2019-01-05T11:30:40-07:00
by fmw42
See https://imagemagick.org/script/command- ... php#define

bmp:subtype=RGB555|RGB565|ARGB4444|ARGB1555 BMP channel depth subtypes. Only support in BMP (BMP4). BMP3 and BMP2 do not contain header fields to support these options.

So in command line IM 7 Q16, it would be:

Code: Select all

magick image.suffix -define bmp:subtype=ARGB1555 -depth 16 result.bmp
Sorry, I do not know how it would be specified in any API. The developers would need to provide that help.


_______________________


Please, always provide your IM version and platform when asking questions, since syntax may differ.

Also provide your exact command line and your images, if possible.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli

Re: Bitmap ARGB1555 image format

Posted: 2019-01-05T11:37:03-07:00
by Coder
Hi,

Thanks for your quick response.
I am using ImageMagick 7.0.7-31 and I am looking for the APIs, since I am using ImageMagick++.

Re: Bitmap ARGB1555 image format

Posted: 2019-01-05T11:59:52-07:00
by snibgo
Coder wrote:... and I am looking for the APIs, since I am using ImageMagick++.
A quick look at coders\bmp.c shows that IM uses GetImageOption to find that you want ARGB1555. So use SetImageOption in MagickCore or Magick++, or MagickSetOption in MagickWand.

Re: Bitmap ARGB1555 image format

Posted: 2019-01-05T23:20:54-07:00
by Coder
Hi,
Thanks for your reply, I didnt see any API called SetImageOption in Magick++. I have seen another api callled "defineValue" where I can give magick option as "bmp" and key as "subtype" and value as "ARGB1555". Is it the right API? How can I get bmp pixels from Image object created???

Re: Bitmap ARGB1555 image format

Posted: 2019-01-06T03:27:52-07:00
by dlemstra
`defineValue` is indeed the correct API. And you probably want to use `getPixels` to get the pixels.

Re: Bitmap ARGB1555 image format

Posted: 2019-01-06T06:10:05-07:00
by Coder
Thanks dlemstra by confirming API :)

But now I am wondering about the performance.
I wanted to scale the image every second or even less. I have tried using "resize" API and then used "scale" API which is even better. And then I have used sample API which makes the cpu usage even better. This will bring down the CPU usage by 5%. Is there any other way we can improve the CPU usage

Re: Bitmap ARGB1555 image format

Posted: 2019-01-06T12:41:44-07:00
by fmw42

Re: Bitmap ARGB1555 image format

Posted: 2019-01-06T21:43:14-07:00
by Coder
Right now we don't have an option for GPU :(. This is an embedded device we have the limitation over hardware resources. Only thing I am trying to achieve is optimize as much as possible. Since you guys are expert in imagemagick, please suggest some of the performance improvement tricks from imagemagick side.

Re: Bitmap ARGB1555 image format

Posted: 2019-01-07T03:25:36-07:00
by snibgo
Sample is quicker than scale, which is quicker than resize. However, for ordinary photos, quicker is also lower quality.

If you have HDRI but don't need it, disabling HDRI will improve performance. Similarly reducing the Q number.

If you have OpenMP, removing it may reduce CPU usage but may also increase execution time

Are you simply doing read-resize-save, or something more complex? If more complex, there may be scope in rearranging the operations.

Re: Bitmap ARGB1555 image format

Posted: 2019-01-07T05:25:41-07:00
by Coder
Interesting!
As you said, I have already done the below steps ( disabled HDRI, Q length is 8 bit) except disabling OpenMP.
Those steps improved performance a lot. I am not doing complex steps, doing text to bmp image conversion basically. But this is very frequent mostly less than a second. Is there any difference between label and annotate in terms of performance? Some how when I use "label " api I am not getting image with text, but annotate worked for me.

Steps which I am doing

Create an image with size ( size got from Font type metrics ) [ Typemtric also consumes CPU]
Annotate with the text - I can see CPU usage over this step
Set the magicktype as "BMP3" - ( I have tried to use define value api to convert the image to ARGB15555, but when i plotted pixel some how I am not getting proper display. Is getPixels is the raw pixels or its also contains bitmap info as well?
Resize image by using sample algm - Performance improved a lot after using sample algorithm
Write to blob and get the bitmap pixel from blob

The above actions are in a loop where loop interval is less than a second

Re: Bitmap ARGB1555 image format

Posted: 2019-01-07T19:54:49-07:00
by Coder
Any thoughts???

Re: Bitmap ARGB1555 image format

Posted: 2019-01-07T20:30:18-07:00
by fmw42
-sample will downsize by skipping pixels and thus will be poor quality. If you can live with that, then it would be the faster of -resize, -scale and -sample.

Re: Bitmap ARGB1555 image format

Posted: 2019-01-07T21:10:44-07:00
by Coder
Thanks for the comment! I am going keep the sample algorithm as as now for scaling.
Is there any difference between annotation and label in terms of performs? Or which is better API for text rendering?

Re: Bitmap ARGB1555 image format

Posted: 2019-01-07T22:13:57-07:00
by fmw42
I do not know which is more efficient. You would have to test that. But -annotate writes directly on the input image. With label:, you must create a new image with transparent background and then composite over the background image. So my guess is that -annotate would be faster. You can also test -draw. It works similar to -annnotate, but I like -annotate better as it is more flexible.