Manipulating Raw Picture Data

Wilhelm Sanke sanke at hrz.uni-kassel.de
Thu Jun 26 15:07:25 EDT 2008


Mark Greenberg markgreenberg at cox.net wrote:

> I have an image where different regions consist of known colors. I  
> would like to fill a region with color at runtime as a sort of  
> highlight. The situation does not lend itself to using separate  
> transparent png images. I have been using the floodfill bucket tool  
> to achieve this, but it is slow and doesn't work right when I compile  
> to standalone.
>
> (snip)
>
> Two questions:  
> would sampling every pixel in a 600x400 image and possibly changing  
> the pixel's color be fast enough to seem like a highlight to the  
> user? and how would I go about doing that?
>
> Thanks in Advance,
>
>     Mark Greenberg



I assume that with highlighting specific regions you mean

- changing the image for a short moment and then revert to the original 
picture?

Chipp's suggestion

> I doubt it will be fast enough for you. Why don't you try using a graphic
> rectangle on top using an ink effect?


seems to me a good starting point.
I have found that for such a rectangle a usable color would be 
236,233,88 with the ink set to "srcAnd" (on Windows, on MacOS you need a 
different ink).

If you want to hilite only specific parts - and maybe regions at the 
same time that are not connected - then create appropriate polygons and 
show/hide them.

I have as one example implemented such an approach in my sample stack 
"Image and Words"

<http://www.sanke.org/Software/ImageAndWords.zip>

Another suggestion:

Change the colors of the image you want to change and save its imagedata 
in a custom property.
Set another custom property to the imagedata of the original image.

Then use a script like this:

on mouseUp
  set the imagedata of img 1 to the cpcolors2 of this card # changed colors
  wait 200 milliseconds # or any time you choose
  set the imagedata of img 1 to the cpcolors1 of this card # original image
end mouseUp

This "highlighting" is instantaneous, but you need to set the 
paintcompression to RLE before (There is definitely no need to set the 
paintcompression to RLE at the time you import the image, the faster 
tempo of RLE will be working any time after you have set it - I think 
this may read differently in the docs, but then the docs are wrong here)

Regards,

Wilhelm Sanke





More information about the use-livecode mailing list