C++ Read Png into opengl

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
joessu
Posts: 5
Joined: 2015-06-09T14:47:27-07:00
Authentication code: 6789

C++ Read Png into opengl

Post by joessu » 2015-06-09T14:55:57-07:00

Very simple thing.

I am getting an odd result.

Code: Select all

Magick::Image im;
        im.magick("PNG");
        im.read(std::string(TEXTURE_DIRECTORY).append(desc.filename)); //"image.png"
        w = im.columns();
        h = im.rows();


        unsigned char* data = new unsigned char[w*h*3];
        im.write(0,0,w,h,"RGB", CharPixel, data);

        tex.widths.push_back(w);
        tex.heights.push_back(h);
        tex.texData.push_back(data);
Here is the result in OGL:

Image

looks like the format remains PNG? what am i missing?

User avatar
magick
Site Admin
Posts: 11062
Joined: 2003-05-31T11:32:55-07:00

Re: C++ Read Png into opengl

Post by magick » 2015-06-09T15:06:26-07:00

Perhaps the image has an alpha channel. Try w*h*4 and RGBA.

joessu
Posts: 5
Joined: 2015-06-09T14:47:27-07:00
Authentication code: 6789

Re: C++ Read Png into opengl

Post by joessu » 2015-06-09T15:12:50-07:00

Ah, i thought that by declaring RGB in write that i could exclude the alpha channel?

EDIT: that didn't do it. the result is different but has same artifacts.

joessu
Posts: 5
Joined: 2015-06-09T14:47:27-07:00
Authentication code: 6789

Re: C++ Read Png into opengl

Post by joessu » 2015-06-10T09:35:49-07:00

When i write it to a png using im.write("test.png"), It writes it perfectly!!!

joessu
Posts: 5
Joined: 2015-06-09T14:47:27-07:00
Authentication code: 6789

Re: C++ Read Png into opengl

Post by joessu » 2015-06-10T09:38:38-07:00

Sorry for spamming, another bit of info. I know my texture code in opengl works because i was using SOIL to do the same exact thing before this

joessu
Posts: 5
Joined: 2015-06-09T14:47:27-07:00
Authentication code: 6789

Re: C++ Read Png into opengl

Post by joessu » 2015-06-11T13:48:39-07:00

So the issue appears to be in my use of the pixel data after this function exits.

Post Reply