support for raw 16-bit RGB565
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: support for raw 16-bit RGB565
I have never seen anything about geometry accepting offset in bytes. Where did you see that? Offset is in pixels according to https://imagemagick.org/script/command- ... p#geometry
Re: support for raw 16-bit RGB565
We'll add a 565 coder within a day or two:
Code: Select all
magick -size 800x600 "RGB565:Loading Default.2rawdata" crest.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: support for raw 16-bit RGB565
"-evaluate LeftShift" and "-evaluate RightShift" implement the C operators "<<" and ">>". See http://www.gnu.org/software/gnu-c-manua ... t-Shifting . These shift, they do not rotate unless the top bit was 1 ("signed negative value"). So we generally need "-evaluate And" to mask the bits.HoraK-FDF wrote:yes that with the And is clear but when shifted on all other languages I know on one side zeroes come in an this would make the And unnecessary so does ImageMagick rotate interanlly meaning the bits leaving on one side come in on the other?
The evaluates can be simplified in a number of ways, such as:
Code: Select all
magick ^
-size 800x600 -depth 16 ^
"GRAY:Loading Default.2rawdata" ^
( -clone 0 -evaluate And 63488 ) ^
( -clone 0 -evaluate And 2016 -evaluate LeftShift 5 ) ^
( -clone 0 -evaluate And 31 -evaluate LeftShift 11 ) ^
-delete 0 ^
-combine ^
f4.png
snibgo's IM pages: im.snibgo.com
Re: support for raw 16-bit RGB565
I've read about it on this pages:fmw42 wrote: ↑2019-06-03T14:36:35-07:00 I have never seen anything about geometry accepting offset in bytes. Where did you see that? Offset is in pixels according to https://imagemagick.org/script/command- ... p#geometry
https://www.imagemagick.org/discourse-s ... hp?t=20324
http://kirste.userpage.fu-berlin.de/che ... nvert.html
There where a few more but I did not find them again.
Thank you very much.magick wrote: ↑2019-06-03T17:07:53-07:00 We'll add a 565 coder within a day or two:
Code: Select all
magick -size 800x600 "RGB565:Loading Default.2rawdata" crest.png
Thank you for the explanation and the simple version.snibgo wrote: ↑2019-06-04T05:01:32-07:00 "-evaluate LeftShift" and "-evaluate RightShift" implement the C operators "<<" and ">>". See http://www.gnu.org/software/gnu-c-manua ... t-Shifting . These shift, they do not rotate unless the top bit was 1 ("signed negative value"). So we generally need "-evaluate And" to mask the bits.
The evaluates can be simplified in a number of ways, such as:Note that 63488 is binary 11111000 00000000, and 2016 is binary 00000111 11100000.Code: Select all
magick ^ -size 800x600 -depth 16 ^ "GRAY:Loading Default.2rawdata" ^ ( -clone 0 -evaluate And 63488 ) ^ ( -clone 0 -evaluate And 2016 -evaluate LeftShift 5 ) ^ ( -clone 0 -evaluate And 31 -evaluate LeftShift 11 ) ^ -delete 0 ^ -combine ^ f4.png
About that problem with the tailing 2400bytes could that be avoided with some kind of option/switch or does ImageMagick needs to be modifyed to do that?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: support for raw 16-bit RGB565
You can use head and tail for that:
Code: Select all
cat "Loading Default.frm16" |head -c -2400 |tail -c +37 |magick ^
-size 800x600 -depth 16 GRAY:- ^
( -clone 0 -evaluate And 63488 ) ^
( -clone 0 -evaluate And 2016 -evaluate LeftShift 5 ) ^
( -clone 0 -evaluate And 31 -evaluate LeftShift 11 ) ^
-delete 0 ^
-combine ^
f6.png
snibgo's IM pages: im.snibgo.com
Re: support for raw 16-bit RGB565
Thanks for the info, but shouldn't ImageMagick be able to do this by itself? Can I ask for this feature to be added maybe right here or should I make a new post?snibgo wrote: ↑2019-06-04T15:11:42-07:00 You can use head and tail for that:Code: Select all
cat "Loading Default.frm16" |head -c -2400 |tail -c +37 |magick ^ -size 800x600 -depth 16 GRAY:- ^ ( -clone 0 -evaluate And 63488 ) ^ ( -clone 0 -evaluate And 2016 -evaluate LeftShift 5 ) ^ ( -clone 0 -evaluate And 31 -evaluate LeftShift 11 ) ^ -delete 0 ^ -combine ^ f6.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: support for raw 16-bit RGB565
You can always ask, in this thread or in the "Developers" subforum.
snibgo's IM pages: im.snibgo.com