本文整理汇总了C++中image::BitmapData::getPixelPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapData::getPixelPointer方法的具体用法?C++ BitmapData::getPixelPointer怎么用?C++ BitmapData::getPixelPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image::BitmapData
的用法示例。
在下文中一共展示了BitmapData::getPixelPointer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeImage
//==============================================================================
void LowLevelGraphicsPostScriptRenderer::writeImage (const Image& im,
const int sx, const int sy,
const int maxW, const int maxH) const
{
out << "{<\n";
const int w = jmin (maxW, im.getWidth());
const int h = jmin (maxH, im.getHeight());
int charsOnLine = 0;
const Image::BitmapData srcData (im, 0, 0, w, h);
Colour pixel;
for (int y = h; --y >= 0;)
{
for (int x = 0; x < w; ++x)
{
const uint8* pixelData = srcData.getPixelPointer (x, y);
if (x >= sx && y >= sy)
{
if (im.isARGB())
{
PixelARGB p (*(const PixelARGB*) pixelData);
p.unpremultiply();
pixel = Colours::white.overlaidWith (Colour (p.getARGB()));
}
else if (im.isRGB())
{
pixel = Colour (((const PixelRGB*) pixelData)->getARGB());
}
else
{
pixel = Colour ((uint8) 0, (uint8) 0, (uint8) 0, *pixelData);
}
}
else
{
pixel = Colours::transparentWhite;
}
const uint8 pixelValues[3] = { pixel.getRed(), pixel.getGreen(), pixel.getBlue() };
out << String::toHexString (pixelValues, 3, 0);
charsOnLine += 3;
if (charsOnLine > 100)
{
out << '\n';
charsOnLine = 0;
}
}
}
out << "\n>}\n";
}
示例2: applyToImage
//==============================================================================
void ImageConvolutionKernel::applyToImage (Image& destImage,
const Image& sourceImage,
const Rectangle<int>& destinationArea) const
{
if (sourceImage == destImage)
{
destImage.duplicateIfShared();
}
else
{
if (sourceImage.getWidth() != destImage.getWidth()
|| sourceImage.getHeight() != destImage.getHeight()
|| sourceImage.getFormat() != destImage.getFormat())
{
jassertfalse;
return;
}
}
const Rectangle<int> area (destinationArea.getIntersection (destImage.getBounds()));
if (area.isEmpty())
return;
const int right = area.getRight();
const int bottom = area.getBottom();
const Image::BitmapData destData (destImage, area.getX(), area.getY(), area.getWidth(), area.getHeight(), true);
uint8* line = destData.data;
const Image::BitmapData srcData (sourceImage, false);
if (destData.pixelStride == 4)
{
for (int y = area.getY(); y < bottom; ++y)
{
uint8* dest = line;
line += destData.lineStride;
for (int x = area.getX(); x < right; ++x)
{
float c1 = 0;
float c2 = 0;
float c3 = 0;
float c4 = 0;
for (int yy = 0; yy < size; ++yy)
{
const int sy = y + yy - (size >> 1);
if (sy >= srcData.height)
break;
if (sy >= 0)
{
int sx = x - (size >> 1);
const uint8* src = srcData.getPixelPointer (sx, sy);
for (int xx = 0; xx < size; ++xx)
{
if (sx >= srcData.width)
break;
if (sx >= 0)
{
const float kernelMult = values [xx + yy * size];
c1 += kernelMult * *src++;
c2 += kernelMult * *src++;
c3 += kernelMult * *src++;
c4 += kernelMult * *src++;
}
else
{
src += 4;
}
++sx;
}
}
}
*dest++ = (uint8) jmin (0xff, roundToInt (c1));
*dest++ = (uint8) jmin (0xff, roundToInt (c2));
*dest++ = (uint8) jmin (0xff, roundToInt (c3));
*dest++ = (uint8) jmin (0xff, roundToInt (c4));
}
}
}
示例3: createConvolvedImageFull
Image RadialImageConvolutionKernel::createConvolvedImageFull (Image const& sourceImage) const
{
// calc destination size based on kernel radius
int dw = sourceImage.getWidth() + 2 * m_radius - 1;
int dh = sourceImage.getHeight() + 2 * m_radius - 1;
Image result (sourceImage.getFormat(), dw, dh, false);
// calc size of edge-replicated source dimensions
int sw = dw + 2 * m_radius - 1;
int sh = dh + 2 * m_radius - 1;
// temp buffer is big enough for the largest edge-replicated line
HeapBlock <uint8> temp;
temp.allocate (jmax (sw, sh), false);
const Image::BitmapData srcData (sourceImage,
Image::BitmapData::readOnly);
const Image::BitmapData destData (result, 0, 0, dw, dh,
Image::BitmapData::readWrite);
int ci[4];
int nc = srcData.pixelStride;
bool alpha = false;
switch (srcData.pixelFormat)
{
case Image::RGB:
ci[0] = PixelRGB::indexR;
ci[1] = PixelRGB::indexG;
ci[2] = PixelRGB::indexB;
nc = 3;
alpha = false;
break;
case Image::ARGB:
ci[0] = PixelARGB::indexR;
ci[1] = PixelARGB::indexG;
ci[2] = PixelARGB::indexB;
ci[3] = PixelARGB::indexA;
nc = 3;
alpha = true;
break;
case Image::SingleChannel:
ci[0] = 0;
nc = 0;
alpha = true;
break;
default:
Throw (Error ().fail (__FILE__, __LINE__));
break;
}
// edge-replicate each row in source to temp, and convolve into dest
for (int y = 0; y < srcData.height; ++y)
{
for (int c = 0; c < nc; ++c)
{
copy (srcData.width,
temp,
1,
srcData.getLinePointer (y) + ci[c],
srcData.pixelStride,
2 * (m_radius - 1));
convolve (destData.width,
destData.getPixelPointer (0, y + m_radius - 1) + ci[c],
destData.pixelStride,
temp,
1,
m_radius,
m_kernel);
}
if (alpha)
{
copy_alpha (srcData.width,
temp,
1,
srcData.getLinePointer (y) + ci[nc],
srcData.pixelStride,
2 * (m_radius - 1));
convolve (destData.width,
destData.getPixelPointer (0, y + m_radius - 1) + ci[nc],
destData.pixelStride,
temp,
1,
m_radius,
m_kernel);
}
}
// edge-replicate each intermediate column from dest to temp, and convolve into dest
for (int x = 0; x < destData.width; ++x)
{
for (int c = 0; c < nc; ++c)
{
//.........这里部分代码省略.........