I have an animated gif image with transparent frames.
I need to resize it.
Before resizing, I use the Magick::coalesceImages function, after I resize the image I use the Magick::writeImages function to collect all the gif frames back into one single image.
The problem is that the output resized image file size is bigger than the original one, because the original animated gif had transparent frames, and the new resized gif does not have any transparent frames.
I have read about frame optimization on www.imagemagick.org plus I can see on www.graphicsmagick.org the gifDisposeMethod function.
My question is, how can I cause the resized animated gif image to use transparency frames and avoid the increase on the image KBytes size?
Well, I found the way to go:
When resizing an animated gif, using Magick::coalesceImages() is not the best way...
Instead I am rezising according to percentage sizing and not absolute sizing, while skipping the Magick::coalesceImages() call.
For example, lets say my original animated gif is 300x300 and I want to resize it to be 150x150, I'll do the following:
Read the image in a Magick::Blob
Calculate the percentage numbers (50%x50% in my demo case)
Resize each and every frame of the image according to the percentage calculations.
This way we are not increasing each frame size because we are not using the Magick::coalesceImages() function and we are resizing each frame according to its original size, so we don't have any problem with the transparency of the frame.
Related
I've got a texture I'm using in OpenGL 4.6 that I want to scale to 2x2, but I'm not sure how. Is there any way to resize an image in a way so that each pixel in the original image is basically duplicated to create a 2x2 in the resized image? I've tried using photoshop to do this, but the image quality always seems to drop significantly. Or do I have to manually create the image myself?
Does Firemonkey have an image manipulation library? Right now I'm doing everything with Canvases and it sucks.
I have a program which currently loads the image into a TBitmap, performs its operations, and then saves the TBitmap object out to a file.
The TBitmap interface however is not ideal. Among the problems...
It silently scales down images which are larger than 8k pixels in any dimension, losing resolution on large .png files
It scales the image whenever there are clipping issues with DrawBitmap which is undesirable (I'd much rather it clip the output or just crash)
Rotating bitmaps is very hard to predict the output of and may scale the image.
I want a better option than canvas methods for image manipulation. I see there are units under Vcl.Imaging, but I can't find anything similar under the FMX units.
The operations I'm really looking for are just drawing lines, text, zooming, rotating, blitting to the display, saving, and loading.
I want the 800x600 png to rotate twice or 3 times per second. Also, could I use a smaller png to increase performance without loosing visual quality?
With C++, SDL2 these are perhaps some methods to do this:
1.Huge 5mb png sprite sheet of the image rotating. Put that into SDL2 and display all the clips in a loop.
2.Get the png into SDL as a texture and use a method/function to rotate it. I haven't seen a clear example of this done...
I am using a DirectShow filtergraph to grab frames from videos. The current implementation follows this graph:
SourceFilter->SampleGrabber->NullRenderer
This works most of the time to extract images frame by frame for further processing. However I encountered issues with some videos that do not have a PAR of 1:1. These images occur stretched in my processing steps.
The only way to fix this I have found for now is to use a VMR9 renderer in windowless mode that uses GetCurrentImage() to extract a bitmap with the correct aspect ratio. But this method is not very useful for continuous grabbing of thousands of frames.
My question now is: what is the best way to fix this problem? Has anyone run into this issue as well?
Sample Grabber gets you frames with original pixels. It is not exactly a problem if there is aspect ratio attached and the pixels are not "square pixels". To convert to square pixels you simply need to stretch the image respectively. It would be easier for you to do this scale step outside of DirectShow pipeline, and you have all data you need: pixels and original media type. You can calculate the corresponding resolution with square pixels and resample the picture.
So I have made this program for a game and need help with making it a bit more automatic.
The program takes in an image and then displays it. I'm doing this over textures in OpenGL. When I take the screenshot of the game it is usually something about 700x400. I input the height and width into my program, resize the image to 1024x1024 (making it a POT texture for better compatibility) by adding blank space (the original image stays at the top left corner and goes all the way to (700,400) and the rest is just blank; does anyone know the term for this?) and then load it into my program and adjust the corners so only the part from (0,0) to (700,400) is shown.
That's how I handle the display of the image. Now, I would like to make this automatic. So I'd take a 700x400 picture, pass it to the program which would get the image's width and height (700x400), resize it to 1024x1024 by adding blank space and then load it.
So does anyone know a C++ library capable of doing this? I would still be taking the screenshot manually though.
I am using the Simple OpenGL Image Library (SOIL) for loading the picture (.bmp) and converting it into a texture.
Thanks!
You don't really have to resize by adding blank space to display image properly. In fact, it's really unefficient way to do it, especially because you store images in .bmp format.
SOIL is able to automatically add the blank space when loading textures - maybe just try to load the file as-is, without doing any operations.
From SOIL Documentation:
Can automatically rescale the image to the next largest power-of-two
size
Can load rectangluar textures for GUI elements or splash screens
(requires GL_ARB/EXT/NV_texture_rectangle)
Anyway, you don't have to use texture to display pixels on the screen. I presume you aren't using shaders for rendering - if it all goes through fixed pipeline, there's glDrawPixels function, which will be much simpler. Just remember to change your SOIL call to SOIL_load_image.