本文整理汇总了C++中magick::Image类的典型用法代码示例。如果您正苦于以下问题:C++ Image类的具体用法?C++ Image怎么用?C++ Image使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scan_image
void scan_image (const char *filename)
{
scanner.reset();
// normally scanner would reset associated decoder,
// but this debug program connects them manually
// (to make intermediate state more readily available)
// so decoder must also be reset manually
decoder.reset();
Magick::Image image;
image.read(filename);
string file = image.baseFilename();
size_t baseidx = file.rfind('/');
if(baseidx != string::npos)
file = file.substr(baseidx + 1, file.length() - baseidx - 1);
ofstream svg((file + ".svg").c_str());
unsigned inwidth = image.columns();
unsigned flush1 = inwidth / 32;
unsigned flush0 = 2;
unsigned width = inwidth + flush1 + flush0;
unsigned height = image.rows();
unsigned midy = (height + 1) / 2 + 2;
image.crop(Magick::Geometry(inwidth, 1, 0, midy));
image.size(Magick::Geometry(width, 1, 0, 0));
svg << "<?xml version='1.0'?>" << endl
<< "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN'"
<< " 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>" << endl
<< "<svg version='1.1' id='top'"
<< " width='10in' height='6in' preserveAspectRatio='xMinYMid slice'"
<< " overflow='visible' viewBox='0,0 " << width * 2 << ",384'"
<< " xmlns:xlink='http://www.w3.org/1999/xlink'"
<< " xmlns='http://www.w3.org/2000/svg'>" << endl
<< "<defs><style type='text/css'><![CDATA[" << endl
<< " * { stroke-linejoin: round; stroke-linecap: round;"
<< " stroke-width: .1; text-anchor: middle;"
<< " image-rendering: optimizeSpeed;"
<< " font-size: 6; font-weight: bold }" << endl
<< " path { fill: none }" << endl
<< " #zero { stroke: #00f }" << endl
<< " #edges { stroke: #f00 }" << endl
<< " #cur-edge { stroke: #f44 }" << endl
<< " #raw { stroke: orange }" << endl
<< " #y0 { stroke: yellow }" << endl
<< " #y1 { stroke: #0c0 }" << endl
<< " #y2 { stroke: #0aa }" << endl
<< " .y1thr { stroke: #f0f }" << endl
<< " rect.bar { fill: black }" << endl
<< " text.bar { fill: white }" << endl
<< " rect.space { fill: white }" << endl
<< " text.space { fill: black }" << endl
<< " text.data { fill: #44f; font-size: 16 }" << endl
<< "]]></style></defs>" << endl
<< "<image width='" << width * 2 << "' height='384'"
<< " preserveAspectRatio='none'"
<< " xlink:href='" << file << ".png'/>" << endl
<< "<g transform='translate(1,384) scale(2,-.5)'>" << endl;
// brute force
unsigned raw[width];
{
// extract scan from image pixels
image.modifyImage();
Magick::Pixels view(image);
Magick::PixelPacket *pxp = view.get(0, 0, width, 1);
Magick::ColorYUV y;
double max = 0;
svg << "<path id='raw' d='M";
unsigned i;
for(i = 0; i < inwidth; i++, pxp++) {
y = *pxp;
if(max < y.y())
max = y.y();
raw[i] = (unsigned)(y.y() * 0x100);
svg << ((i != 1) ? " " : " L ") << i << "," << raw[i];
y.u(0);
y.v(0);
*pxp = y;
}
y.y(max); /* flush scan FIXME? */
for(; i < inwidth + flush1; i++) {
raw[i] = (unsigned)(y.y() * 0x100);
svg << " " << i << "," << raw[i];
*pxp++ = y;
}
y.y(0);
for(; i < width; i++) {
raw[i] = (unsigned)(y.y() * 0x100);
svg << " " << i << "," << raw[i];
*pxp++ = y;
}
view.sync();
svg << "'/>" << endl
<< "</g>" << endl;
}
image.depth(8);
image.write(file + ".png");
// process scan and capture calculated values
//.........这里部分代码省略.........
示例2:
void Magick::composeImage::operator()( Magick::Image &image_ ) const
{
image_.compose( _compose );
}
示例3: DoDisplayImage
void CIMDisplayView::DoDisplayImage( Image &inImage, CDC* pDC )
{
// make sure we're getting a valid image!
if (!inImage.isValid())
{
return;
}
// if the view is dirty, dispose the old offscreen!
if ( mViewDirty == true ) {
delete mOffscreenDC;
mOffscreenDC = NULL;
}
// make sure we have a valid destination DC
if (pDC != NULL)
{
// if we don't already have a ready offscreen, then prepare one
if ( !mOffscreenDC ) {
//
// Set up the Windows bitmap header
//
BITMAPINFOHEADER bmi;
bmi.biSize = sizeof(BITMAPINFOHEADER); // Size of structure
bmi.biWidth = inImage.columns(); // Bitmaps width in pixels
bmi.biHeight = (-1)*inImage.rows(); // Bitmaps height n pixels
bmi.biPlanes = 1; // Number of planes in the image
bmi.biBitCount = 32; // The number of bits per pixel
bmi.biCompression = BI_RGB; // The type of compression used
bmi.biSizeImage = 0; // The size of the image in bytes
bmi.biXPelsPerMeter = 0; // Horizontal resolution
bmi.biYPelsPerMeter = 0; // Veritical resolution
bmi.biClrUsed = 0; // Number of colors actually used
bmi.biClrImportant = 0; // Colors most important
mBMI = bmi; // keep it for clipboard use...
RGBQUAD *prgbaDIB = 0;
HBITMAP hBitmap = CreateDIBSection
(
pDC->m_hDC, // handle to device context
(BITMAPINFO *)&bmi, // pointer to structure containing bitmap size, format, and color data
DIB_RGB_COLORS, // color data type indicator: RGB values or palette indices
(void**)&prgbaDIB, // pointer to variable to receive a pointer to the bitmap's bit values
NULL, // optional handle to a file mapping object
0 // offset to the bitmap bit values within the file mapping object
);
if ( !hBitmap )
{
CString message;
message.FormatMessage("Windows failed to allocate bitmap of size %1!d!x%2!d!!",
inImage.rows(), inImage.columns());
DoDisplayError("DoDisplayImage",message);
return;
}
//
// If image is non-opaque, apply a pattern background so
// non-opaque regions become evident.
//
Magick::Image image=inImage;
if (inImage.matte())
{
Magick::Image texture;
texture.read("image:checkerboard");
image.texture(texture);
image.matte(false);
}
//
// Extract the pixels from Magick++ image object and convert to a DIB section
//
const unsigned int columns = image.columns();
const unsigned int rows = image.rows();
RGBQUAD *pDestPixel = prgbaDIB;
for( unsigned int row = 0 ; row < rows ; row++ )
{
const PixelPacket *pPixels = image.getConstPixels(0,row,columns,1);
#if QuantumDepth == 8
// Form of PixelPacket is identical to RGBQUAD when QuantumDepth==8
memcpy((void*)pDestPixel,(const void*)pPixels,sizeof(PixelPacket)*columns);
pDestPixel += columns;
#else // 16 or 32 bit Quantum
// Transfer pixels, scaling to Quantum
for( unsigned long nPixelCount = columns; nPixelCount ; nPixelCount-- )
{
pDestPixel->rgbRed = ScaleQuantumToChar(pPixels->red);
pDestPixel->rgbGreen = ScaleQuantumToChar(pPixels->green);
pDestPixel->rgbBlue = ScaleQuantumToChar(pPixels->blue);
pDestPixel->rgbReserved = 0;
++pDestPixel;
++pPixels;
}
#endif
}
//.........这里部分代码省略.........
示例4:
GradientCalculator::GradientCalculator(Magick::Image& image) {
m_pixels = image.getConstPixels(0, 0, image.columns(), image.rows());
m_size.Set(image.columns(), image.rows());
}
示例5:
void Magick::strokeColorImage::operator()( Magick::Image &image_ ) const
{
image_.strokeColor( _strokeColor );
}