Hi,
1)
I've checked the Q&A; in the forum about releasing buffer that is created by "E2DSurfaceRGBA()" or "E2DSurface()", you said we DON'T need to free it when the image is identical. But, I also checked someone said we need to use surface->Free() to free unused buffer. What's the correct usage for using CreateSurface()?
2)
We wanna load image (using creaeSurface)so many times(to avoid image crash when resizing image).
But it's really heavy loading when we use createSurface so many times, do you have good suggestion to use createSurface in many times?
Thanks!
Hi,
In most programs you don't call Free(), you just call CreateSurface (also on existing surfaces). When calling CreateSurface on an existing surface, this is the EDGELIB behaviour:
- If the dimensions (width/height) is the same, call Clear() on the surface before loading data
- If the dimensions are different, call Free() on the surface
This is all handled internally, as a developer you don't need to worry about it. An example where calling Free() yourself could be useful:
When exiting the game, free in-game resources before loading logo's, backdrop's, etc. for the end-of-game screen (for example, an advertisement banner). This decreases memory usage.
Hi,
If we want to resize the surface in many times with non-proportional scale (we can only use BltFast).
We found that the image is screwed up after resize so many times.
So, we choose to createSurface again and again to prevent this issue.
But createSurface spent 0.3s in every function call.(we have +10 images)
Can you kindly suggest us a good way to perform resize action on image? or any other good idea to load surface in efficient way?
MAMAHOW
Hi,
If you need a resize every frame we recommend using the Blt() function to scale your images. If not, we suggest the following method:
- Load the original image in a surface and keep it in the same state (don't call resize on it)
- Create a second surface to contain the resized picture
- Recreate the second surface each time you like to resize the picture. Create an empty surface with the same width/height of the source surface
- BltFast the source surface on the second surface
- Resize the second surface and use it in your application
Hi,
Thanks for your suggestion!
But, what if "NON-proportional" resize?
Based on the document, we can only use BltFast(), right?
And how about BltFx()? The same logic you suggested to use it?
Thanks,
MAMAHOW
Hi,
If you're using RGBA surface, then Resize is the only way to go at the moment.
If you're using regular (RGB) surfaces, then you can use BltFx. This function can take seperate parameters for horizontal and vertical scaling. However, the result doesn't look as good as when using the Resize function, but it does increase performance.