We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I used resize to scale a 1000x1000 image to 500x500 But then the original 1000x1000 image is gone. I have to reload it each time, do my thresholding and then scale it down for display each time.
Is there a way to keep the original image after thresholding each time and display the scaled version without having to reload the original each time?
A non destructive resizing to a new smaller image without using brute force loops to create the new scaled image with a new name? if i do a img.resize the original img is gone.
Answers
Copy the original image into a tmp image. Resize the tmp image.
ok tryed that
(at this point both height and width =1000) tmpimg.resize(100,100)
I printed height and width of both at this point and img is now 100x100 as well!
I didn't resize img
tmpimg.resize changed both?????
what gets printed
https://forum.Processing.org/two/discussion/18109/how-can-i-clone-an-image-object
https://forum.Processing.org/two/discussions/tagged?Tag=get()
So tmpimg and img are not totally different mem space variables trying to understand how processing works compared to C if i create 2 image variable type PImage are they llike pointers in C? They just point to a space? So is there a syntax for taking a whole image and duplicating it in another space and setting a pointer to point to it?
Pointers, references, memory addresses mean the same thing! (:|
Just use PImage's get() method in order to get a clone of it: *-:)
https://Processing.org/reference/PImage_get_.html
There's a copy () method on the pimage class.
Untested but i'd've thought this would work
Yes copy() will work
I get error : The method copy(int,int,int,int,int,int,int,int) is the type PImage is not applicable for the arguments() So do i need to provide values for copy or is copy() acceptable in another version? Using 2.2.1
copy() has NO arguments it makes a full copy of the image which you can resize leaving the original unaffected.