How can I "draw"\"merge" a png top of another png (background) using libpng, while keeping the alpha section of the png being drawn on top of the backhround png. There does not seem to be any tutorials or anything mentioned in the documentation about it.
libpng is a library for loading images stored in the PNG file format. It is not a library for blitting images, compositing images, or anything of that nature. libpng's basic job is to take a file or memory image and turn it into an array of color values. What you're talking about is very much out of scope for libpng.
If you want to do this, you will have to do the image composition yourself manually. Or use a library that can do image composition (cairo, etc).
Related
Is there a way to output a text at some (x,y) position having a certain "size", such as a numeral '1'? For example in gnuplot, we can use
plot ... using x:y:size w labels center...
Is there something similar which I can use with the libjpeg library?
No
libJPEG is only a loading/saving library. It allows the conversion of JPEG to other more workable formats and back. You will need some sort of image processing library (e.g. OpenCV) or high-level graphics library (e.g. DirectX, SFML). There are a lot of image libraries that implement writing of text on a bitmap. libJPEG will allow you to decode into a bitmap format in memory and from there you can work with pretty much any other library that has functions that write text onto a bitmap.
Personally, I would just use SFML since you can load a JPG file (or any image format for that matter), set that texture as a render target, render text, and then get the texture for that and save it back. But any high level graphics library should do the trick...like listed above.
In OpenGL you could read a BMP file and use it as texture.
I know how to read a BMP file in OPENGL.
I just want to know if is it the same thing with JPG or JPEG files? is OpenGL support those files?
OpenGL does not support BMP files. It just cares about raw image date as one-, two or threedimensional arrays of pixel data with up to 4 channels (and a set of different data types). OpenGL does not even know what a file is. And it can't load anything. If you need JPEG files, you have to load them via other means, like libjpeg or some higher level image loading libraries or some of the other image loading libraries.
I would like to write CPP code that is able to take in a PNG file, scan through its pixels and identify where the transparent pixels are.
I tried doing this with CIMG, but it didn't work out as CIMG only supports the RGB channels. Even after installing image magick, the 4th channel is not giving me the right values.
Anyone can suggest a library I could use?
I'm having a few issues regarding how to render a PVR.
I'm confused about how to get the data from the PVR to screen. I have a window that is ready to draw a picture and I'm a bit stuck. What do I need to get from the PVR as parameters to then be able to draw a texture? With jpeg and pngs locally you can just load the image from a directory but how would the same occur for a PVR?
Depends what format the data inside the PVR is in. If it's a supported standard then just copy it to a texture with glTexSubImage2D(), otherwise you will need to decompress it into something OpenGL understands - like RGB or RGBA.
edit - OpenGL is a display library (well much much more than that), it doesn't read images, decode movies or do sound.
TGA files are generally very simple uncompressed RGB or RGBA image data, it should be trivial to decode the file, extract the image data and copy it directly to an opengl texture.
since you tagged the question Qt you can use QImage to load the tga and Using QImage with OpenGL
I need to load PNGs and JPGs to textures. I also need to save textures to PNGs. When an image exceeds GL_MAX_TEXTURE_SIZE I need to split the image into separate textures.
I want to do this with C++.
What could I do?
Thank you.
I need to load PNGs and JPGs to textures
SDL_Image
Qt 4
or use libpng and libjpeg directly (you don't really want to do that, though).
When an image exceeds GL_MAX_TEXTURE_SIZE I need to split the image into separate textures.
You'll have to code it yourself. It isn't difficult.
DevIL can load and save many image formats including PNG and JPEG. It comes with helper functions that upload these images to OpenGL textures (ilutGLBindTexImage, ilutGLLoadImage) and functions to copy only parts of an image to a new image (ilCopyPixels, can be used to split large textures).
For the loading part SOIL looks rather self-contained.