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

Not so smart pick !

 [1/4] from: reboler:ifrance at: 28-Dec-2002 12:28


Hi List, Trying to manipulate image, I have found this :
>> i: make image! 2x2
== make image! [2x2 #{000000000000000000000000}]
>> poke i 2 white
== make image! [2x2 #{000000FFFFFF000000000000}]
>> white
== 255.255.255
>> pick i 2
== 255.255.255.0 Pick seems to be right for locating the value, but wrong when picking it. We got an extra byte. From RCUG (rebolcore-16.html#_Toc487519976), it looks like a bug to me: <<The pixel values of an image are obtained using pick and changed using poke . The value returned by pick is an RGB tuple value. The value replaced with poke also should be a tuple value. Picking specific pixels: probe pick img 1 probe pick img 1500 Poking specific pixels: poke img 1 255.255.255 probe pick img 1
>>
Is there a way of getting rid of the extra byte?
>> pix: pick i 2 >> remove back tail pix ; not good >> pix: copy/part pix 3 ; not good
Regards Patrick Note: already sent to feedback (Feedback Id #2cs322060) _____________________________________________________________________ GRAND JEU SMS : Pour gagner un NOKIA 7650, envoyez le mot IF au 61321 (prix d'un SMS + 0.35 euro). Un SMS vous dira si vous avez gagné. Règlement : http://www.ifrance.com/_reloc/sign.sms

 [2/4] from: carl:cybercraft at: 29-Dec-2002 15:33


On 29-Dec-02, pat665 wrote:
> Hi List, > Trying to manipulate image, I have found this :
<<quoted lines omitted: 8>>
> Pick seems to be right for locating the value, but wrong when > picking it. We got an extra byte.
What version are you using? I get...
>> img: make image! 2x2
== make image! [2x2 #{000000000000000000000000}]
>> poke img 2 1.2.3
== make image! [2x2 #{000000030201000000000000}]
>> pick img 2
== 1.2.3 with View 1.2.1. If a later version though, I wouldn't think it's a bug, but just support for 24bit images. (If that's the case though, then the image's binary display should be showing 16 bytes and not just 12, so that could be considered a bug.) I assume you can poke in a 4-byte tuple and get the correct 4-byte tuple back with pick?
> From RCUG (rebolcore-16.html#_Toc487519976), it looks like a bug to > me:
<<quoted lines omitted: 12>>
>>> remove back tail pix ; not good >>> pix: copy/part pix 3 ; not good
Tuples aren't series, unfortunately, which is why that approach doesn't work. The following will do what you want, but there may be a better way...
>> tup: 1.2.3.4
== 1.2.3.4
>> make tuple! reduce [tup/1 tup/2 tup/3]
== 1.2.3 You could also get the 3-byte tuple directly from the image, since they are a series...
>> img: make image! 2x2
== make image! [2x2 #{000000000000000000000000}]
>> poke img 2 1.2.3
== make image! [2x2 #{000000030201000000000000}]
>> make tuple! to-binary copy/part skip img 5 3
== 1.2.3 Hmmm. Anyone know the reason why make image! displays its binary values the other way around to how normal binaries are displayed? ...
>> to-binary img
== #{00000000000102030000000000000000} -- Carl Read

 [3/4] from: anton:lexicon at: 29-Dec-2002 14:27


That extra byte is for the alpha channel that was added in the latest view betas. (At least versions 1.2.5 and 1.2.8) You should check here before posting to feedback. Anton.

 [4/4] from: reboler:ifrance at: 29-Dec-2002 11:08


Hi Anton, You said :
>You should check here before posting to feedback
That's what I usually do. In that particular case, I was pretty sure it was a bug. In my mind, poke and pick have to be reciprocal. May be you may share with us why it's not the same for you. Regards Patrick

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted