Page 2 of 2

Re: support for raw 16-bit RGB565

Posted: 2019-06-03T14:36:35-07:00
by fmw42
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

Posted: 2019-06-03T17:07:53-07:00
by magick
We'll add a 565 coder within a day or two:

Code: Select all

magick -size 800x600 "RGB565:Loading Default.2rawdata" crest.png

Re: support for raw 16-bit RGB565

Posted: 2019-06-04T05:01:32-07:00
by snibgo
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?
"-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:

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
Note that 63488 is binary 11111000 00000000, and 2016 is binary 00000111 11100000.

Re: support for raw 16-bit RGB565

Posted: 2019-06-04T14:38:33-07:00
by HoraK-FDF
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
I've read about it on this pages:
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.
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 very much.
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:

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
Note that 63488 is binary 11111000 00000000, and 2016 is binary 00000111 11100000.
Thank you for the explanation and the simple version.

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?

Re: support for raw 16-bit RGB565

Posted: 2019-06-04T15:11:42-07:00
by snibgo
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

Re: support for raw 16-bit RGB565

Posted: 2019-06-05T12:33:44-07:00
by HoraK-FDF
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
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?

Re: support for raw 16-bit RGB565

Posted: 2019-06-05T12:39:16-07:00
by snibgo
You can always ask, in this thread or in the "Developers" subforum.