Bitmap ARGB1555 image format

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Coder
Posts: 15
Joined: 2019-01-05T11:15:30-07:00
Authentication code: 1152

Bitmap ARGB1555 image format

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bitmap ARGB1555 image format

Post 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
Coder
Posts: 15
Joined: 2019-01-05T11:15:30-07:00
Authentication code: 1152

Re: Bitmap ARGB1555 image format

Post 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++.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Bitmap ARGB1555 image format

Post 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.
snibgo's IM pages: im.snibgo.com
Coder
Posts: 15
Joined: 2019-01-05T11:15:30-07:00
Authentication code: 1152

Re: Bitmap ARGB1555 image format

Post 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???
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Bitmap ARGB1555 image format

Post by dlemstra »

`defineValue` is indeed the correct API. And you probably want to use `getPixels` to get the pixels.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Coder
Posts: 15
Joined: 2019-01-05T11:15:30-07:00
Authentication code: 1152

Re: Bitmap ARGB1555 image format

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bitmap ARGB1555 image format

Post by fmw42 »

Coder
Posts: 15
Joined: 2019-01-05T11:15:30-07:00
Authentication code: 1152

Re: Bitmap ARGB1555 image format

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Bitmap ARGB1555 image format

Post 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.
snibgo's IM pages: im.snibgo.com
Coder
Posts: 15
Joined: 2019-01-05T11:15:30-07:00
Authentication code: 1152

Re: Bitmap ARGB1555 image format

Post 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
Coder
Posts: 15
Joined: 2019-01-05T11:15:30-07:00
Authentication code: 1152

Re: Bitmap ARGB1555 image format

Post by Coder »

Any thoughts???
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bitmap ARGB1555 image format

Post 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.
Coder
Posts: 15
Joined: 2019-01-05T11:15:30-07:00
Authentication code: 1152

Re: Bitmap ARGB1555 image format

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bitmap ARGB1555 image format

Post 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.
Post Reply