Code::Blocks and Magick++.h
Herbert Elwood Gilliland III <[email protected]> Fri, 12 Apr 2013 00:47:48 -0400
| Newsgroups | gmane.comp.video.graphicsmagick.apis |
|---|---|
| Message-ID | <CAG+GTidn=Xp9ZzqTqrVUm9CYrP0A=+rf+JLgH=aAR2Df5WE8WA@mail.gmail.com> |
I want to use ImageMagick / GraphicsMagick to load texture data into OpenGL
as a cross-platform solution. I'm using Code::Blocks. I cannot find good
information regarding use of ImageMagick in Code::Blocks.
1) Does anyone have a working, relatively recent and definitive guide to
getting Code::Blocks to find and properly use Magick++.h? I am using the
OpenGL template for mingw/gcc on Windows platform.
2) I have written this code for Loading, which loads an image into a "CPU
Image" based from data collected by Magick++.h -- I have another version
that uses GDI+ as a fallback for MSVC++. Is this what it should be?
bool Load( string filename, Indexed<GLubyte> *pixels, int *w, int *h ) {
Magick::Image magick();
magick.read(filename.c_str());
*w=(int) magick.GetWidth();
*h=(int) magick.GetHeight();
Magick::Color sample;
(*pixels).Size( (size_t) w * 4, (size_t) h );
PixelPacket *pix=magick.getPixels(0,0,w,h);
for ( int x=0; x<w; x++ ) for ( int y=0; y<h; y++ ) {
sample = pix[w*y+x];
(*pixels)(x ,y) = (GLubyte) ( iratiod(sample.blueQuantum(),
(double) MaxRGB)*255.0 );
(*pixels)(x + 1,y) = (GLubyte) ( iratiod(sample.greenQuantum(),
(double) MaxRGB)*255.0 );
(*pixels)(x + 2,y) = (GLubyte) ( iratiod(sample.redQuantum(),
(double) MaxRGB)*255.0 );
(*pixels)(x + 3,y) = (GLubyte) ( 1.0 / iratiod(sample.alphaQuantum(),
(double) MaxRGB)*255.0 );
}
return true;
}
The Indexed template is similar to a stl vector.
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Graphicsmagick-apis mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis