scaling an image within a pixmap
Hello everyone!
I'm trying to add in a dialog several pixmaps with images loaded somewhere else in the script. This is not fundamental, but this would be "much more cute" this way (gosh, it's always like this when women are scripting?!).
For now I have no issue to add the pixmap with the "big" image, my issue is the scale of the initial images. In general they are big images (>2000x2000) that I want to fit in a 200x200 pixmap (the pixmap supported by a DzLabel in the dialog : "wLabel.pixmap").
So far I tried :
- to use the Qt commands : scaledToWidth/ scaledToHeight but I failed
- the pixmap.resize(size), which crops the image, (well it does what it supposed to do : resize the pixmap, not the image)
- to load the file as an image "Image(sAbsolutePath)", rescale it, and place it directly in the pixmap, but this method does not seem to be supported (pixmap seems to need a path to be loaded). I tried the Qt function fromImage() to create the function from the image but once again I did not manage to use it.
- to load the file as an image "Image(sAbsolutePath)", rescale it, save it, and then the pixmap calls the image just saved. This could be the solution, my worry is being that I will have to save it, probably in a temp folder, and I don't know how to grab the temp folder of the user, and if I have to clean it or not at the end of the script.
Finally I decided to come here to ask the questions about what is the best way to rescale an image to place in a PixMap. Or maybe is there another solution, something else than the pixmap?
If there is no other solution, I guess I'm supposed to write temporary images in the "temp" file of the user, but is there a way to access the path of this file?
Thanks in advance for any help!
Comments
The best way to handle this situation is:
Thanks again jag11!!!!
It was the App.getTempPath() that I was looking for (I did not know this existed, this is really cool to know where to place temp files).. For the rest, all the subpart of the script it should be ok, I have already made small parts here and there! (I'm not a "real" scripter, I feel much more like Champollion during its first days with the Rosetta Stone).
For the point 5, images will always be different, they are not linked to my product but to surfaces in the scene, so I'll try to find the best moment to delete them in the script.
That's really great, now I'll be able to see it my dialog is "more cute" with these pixmaps or not.
There is no better way? My problem is I need to to this on a "slider movement" and this way you end up with the issue it takes too long before the next slider value changed callback fires, OK, I know I can wrap it in code to semaphore it so it wont load the last one when a new is incoming, but I was hoping for a less cludgy way of doing this.
Cheers,
/Totte
Maybe using manipulators is the way to go, I would need to do some testing. There is an interesting class DzScaleManip that could be fast enough for that purpose.
By using the Image Manager you can load an image and get a preview image with any desired size, it is very fast.
Made a dialog with several labels with a small preview from a big image, Image Manager optimizes everything for you.
You and Image Manager are both so cool! Thanks!