Manipulating Raw Picture Data
viktoras didziulis
viktoras at ekoinf.net
Thu Jun 26 05:16:57 EDT 2008
just played around a little with this handler on 600x500 image (MS
Windows XP, RR 2.9, Intel Celeron 1500 MHz):
on repColor
local myData
local myTimer
local myColor1
local myColor2
put binaryEncode("C3",myRed,myGreen,myBlue) into myColor1
put binaryEncode("C3",myRed2,myGreen2,myBlue2) into myColor2
put the milliseconds into myTimer
put the imageData of img "im1" into myData
replace myColor1 with myColor2 in myData
set the imageData of img "im1" to myData
put (the milliseconds) - myTimer & return after fld "fTimer"
end repColor
in development environment with paintcompression set to default ("PNG")
it takes around 635 milliseconds.
If before loading your image you do this: set the paintcompression to
"RLE" (which is the default in standalones)
the same color replacement handler takes just 77 milliseconds, which is
~ 9 times faster!
Now if only we'd know what exactly rle format is used by RR, then we
should be able to do:
put the text of img "im1" into myData
replace myColor1 with myColor2 in myData
set the text of img "im1" to myData
unfortunately now this damages the image but otherwise it would take
only ~25 milliseconds.
All the best!
Viktoras
Mark Greenberg 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.
>
> I've read various threads on manipulating the raw picture data and
> seen a couple of stacks like that. It seems a bit beyond my skills as
> a casual programmer, but I may need to give it a try. 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
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
More information about the use-livecode
mailing list