copyimagerect?

Monkey Forums/Monkey Programming/copyimagerect?

Paul - Taiphoz(Posted 2013) [#1]
is there such a thing, or an easy way to for example have an image, with some alpha values in it, and copy the image or part of the image into another image and have it overwrite the appropriate pixels ?


MikeHart(Posted 2013) [#2]
Into an existing image? Only via Readpixel and WritePixel.


Shinkiro1(Posted 2013) [#3]
Unfortunately, using ReadPixel there is no way to read the alpha channel.
Something like BMax Pixmaps would be required. I think minib3d has some pixmap code, would be great if it could be used independently from the module.


Midimaster(Posted 2013) [#4]
If there is a mthod WritePixel() that knows how to manipulate pixels in Images, I cannot believe, that there should no way to also read this pixels...

Perhaps Mark can tell us, why the WritePixels() could not be the inverse function the of ReadPixels().

At the moment you can draw the image to the screen, then read its pixels into an array, then write the array to a second image.

There is also a theoretic way of reading the alpha channel. I used this for my speed up function for angelfont

http://www.monkeycoder.co.nz/Community/posts.php?topic=4893#53368

You can draw the image on a black background, then store pixels into a first array, then draw the same image again on a white background and store the pixels to a second array.
Now Compare the arrays:
1.
All pixels, which have the same value have Alpha=1.

2.
All pixels, which have the 0,0,0 in black and 255,255,255 in white have the Alpha=0

3.
I'm sure there is a formula to define all "mixed" pixels


Paul - Taiphoz(Posted 2013) [#5]
its definitely a function that would be handy, I was thinking of a way to implement multipule light's via a black cover the size of the screen and then using a method to draw over some alpha headlights or spotlights into that black.

seems speed would be a big issue tho if read and write pixel is overused, with a little luck mark might have some ideas on how this could be done.