Want to copy part of an image fully to another part of an image, but write alphas with it.
-
Any idea on how to do this? From what I can tell, the draw functions take alpha into account for how they write pixels. Any pixels with an alpha of 0 simply don't get written, when what I want to do is write all pixels, along with their alpha values. Only function I saw that could possibly do that is
copyImage
, but that simply makes a new image when I don't want to make a new image, but copy part of an image into a section of another image I designate, alphas and all. -
If the image is set to image_rgba, this should work:
setDrawTarget(img1) clear({0, 0, 0, 0}) drawImage(img2, 0, 0)
-
@Nisse5 said in Want to copy part of an image fully to another part of an image, but write alphas with it.:
If the image is set to image_rgba, this should work:
setDrawTarget(img1) clear({0, 0, 0, 0}) drawImage(img2, 0, 0)
But I'm looking to write to a part of an image, leaving the rest intact. Unless
clear()
can be limited to an area rather than the whole, it would clear the entire image. -
@Discostew
In that case, use box() instead of clear(). Haven't tried it but it should work?EDIT: On second though that would probably just paint nothing. -
I'm not sure if this is the help that you need @Discostew because in truth this isn't something I've had little experience with, but you can use this form of drawImage():
drawImage( img, {sourceX, sourceY, sourceW, sourceH}, {destX, destY, destW, destH} )
To select a portion of a created image and draw at any scale. I hope this helps, even if a little!
-
Did you try to modify the drawing mode, with setBlend() ?
-
@doumdoum Ah, that's it! I never checked it because I thought that worked differently. Thank you!