Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Alpha channel of image! type

From: petr:krenzelok:trz:cz at: 14-Nov-2002 19:00

Hi, I am not sure I can completly answer your question, but look at least into following hints: ->> img: load %carlwaves.jpg == make image! [128x128 #{ 66191C681B1E6A1D20671A1D65181B681B1E702326772A2D74272A6A1D20 6114176215186C1F2275282B782B2E732A2C601E1F7... now you can know each pixel: ->> img/1 == ->> img/2 == As you can see, four bytes are used, zero represents value of alpha channel here .... But notice, that rebol presents data in BGR reverse format ... ->> to-integer #{66} == 102 ->> to-integer #{19} == 25 ->> to-integer #{1C} == 28 ->> to-integer #{68} == 104 From above you can see, that alpha channel is not presented in ==make image! output .... simple example of how to change alpha value of image to let's say value of 100: ->> for i 1 (length? img) / 4 1 [poke img i to-tuple join img/:i/1 ["." img/:i/2 "." img/:i/3 "." 100]] ->> view layout [image img] So possibly, as for your example: R: copy [] G: copy [] B: copy [] A: copy [] for i 1 (length? img) / 4 1 [append R img/:i/1 append G img/:i/2 append B img/:i/3 append A img/:i/4] So, that's it ... the code is nice looking and simple, isn't it? The problem is, that for image manipulation, forget speed. Unless RT adds compile to at least some areas of usage, you will have to either wait a bit when manipulating large image, or go for C library, but you would need /Pro version ... HTH, -pekr- Claude Precourt wrote: