Q: Can I use only a part of an Image File and do stuff with it ?
Phil Davis
revdev at pdslabs.net
Thu Oct 1 16:28:29 EDT 2009
Hi Rolf,
Here's another solution (I needed to unwind before getting back to work).
I made a stack, imported an image and made its height 1/10 of its width.
Then I created a button and gave it the following script. Click the
button and *poof* it works.
This only handles 'the imageData' of the image, so screen resolution is
the true resolution of the new images.
Hope this helps -
Phil Davis
on mouseUp
if (width of img 1) mod 10 <> 0 then
answer "Bad image width (not evenly divisible by 10)."
exit to top
end if
put (width of img 1) / 10 into tFramePixelWidth
put tFramePixelWidth * 4 into tFrameByteWidth -- 4 bytes per pixel
-- split image data into 10 frames
put the imageData of img 1 into tImageData
repeat with H = 1 to the height of img 1 -- for each line of pixels
repeat with W = 1 to 10 -- for each frame segment per line
put byte 1 to tFrameByteWidth of tImageData after tData[W]
delete byte 1 to tFrameByteWidth of tImageData
end repeat
end repeat
-- create 10 image objects and load them with data
put "-50,220,50,320" into tRect
repeat with x = 1 to 10
add tFramePixelWidth to item 1 of tRect
add tFramePixelWidth to item 3 of tRect
set the rect of the templateImage to tRect
create image
set the imageData of last image to tData[x]
end repeat
end mouseUp
Rolf Kocherhans wrote:
> For instance I have an imported Image file (png) 10 pixels high and
> 100 pixels long.
>
> From pixel 1 to 10 ist Picture_one, from pixel 11 to 20 is Picture
> _two etc.
>
> Can I the display those 2 respectively 10 pictures individually ?
>
> Cheers
> Rolf
--
Phil Davis
PDS Labs
Professional Software Development
http://pdslabs.net
More information about the use-livecode
mailing list