本文整理汇总了C++中image::BitmapData类的典型用法代码示例。如果您正苦于以下问题:C++ BitmapData类的具体用法?C++ BitmapData怎么用?C++ BitmapData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BitmapData类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void paint (Graphics& g)
{
if (colours.isNull())
{
const int width = getWidth() / 2;
const int height = getHeight() / 2;
colours = Image (Image::RGB, width, height, false);
Image::BitmapData pixels (colours, Image::BitmapData::writeOnly);
for (int y = 0; y < height; ++y)
{
const float val = 1.0f - y / (float) height;
for (int x = 0; x < width; ++x)
{
const float sat = x / (float) width;
pixels.setPixelColour (x, y, Colour (h, sat, val, 1.0f));
}
}
}
g.setOpacity (1.0f);
g.drawImage (colours, edge, edge, getWidth() - edge * 2, getHeight() - edge * 2,
0, 0, colours.getWidth(), colours.getHeight());
}
示例2: 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";
}
示例3: handleFrame
void handleFrame (double /*time*/, BYTE* buffer, long /*bufferSize*/)
{
if (recordNextFrameTime)
{
const double defaultCameraLatency = 0.1;
firstRecordedTime = Time::getCurrentTime() - RelativeTime (defaultCameraLatency);
recordNextFrameTime = false;
ComSmartPtr<IPin> pin;
if (getPin (filter, PINDIR_OUTPUT, pin))
{
ComSmartPtr<IAMPushSource> pushSource;
HRESULT hr = pin.QueryInterface (pushSource);
if (pushSource != nullptr)
{
REFERENCE_TIME latency = 0;
hr = pushSource->GetLatency (&latency);
firstRecordedTime = firstRecordedTime - RelativeTime ((double) latency);
}
}
}
{
const int lineStride = width * 3;
const ScopedLock sl (imageSwapLock);
{
loadingImage.duplicateIfShared();
const Image::BitmapData destData (loadingImage, 0, 0, width, height, Image::BitmapData::writeOnly);
for (int i = 0; i < height; ++i)
memcpy (destData.getLinePointer ((height - 1) - i),
buffer + lineStride * i,
lineStride);
}
imageNeedsFlipping = true;
}
if (listeners.size() > 0)
callListeners (loadingImage);
sendChangeMessage();
}
示例4: convert
Image ImageType::convert (const Image& source) const
{
if (source.isNull() || getTypeID() == (ScopedPointer<ImageType> (source.getPixelData()->createType())->getTypeID()))
return source;
const Image::BitmapData src (source, Image::BitmapData::readOnly);
Image newImage (create (src.pixelFormat, src.width, src.height, false));
Image::BitmapData dest (newImage, Image::BitmapData::writeOnly);
jassert (src.pixelStride == dest.pixelStride && src.pixelFormat == dest.pixelFormat);
for (int y = 0; y < dest.height; ++y)
memcpy (dest.getLinePointer (y), src.getLinePointer (y), (size_t) dest.lineStride);
return newImage;
}
示例5: convert
Image ImageType::convert (const Image& source) const
{
if (source.isNull() || getTypeID() == (std::unique_ptr<ImageType> (source.getPixelData()->createType())->getTypeID()))
return source;
const Image::BitmapData src (source, Image::BitmapData::readOnly);
Image newImage (create (src.pixelFormat, src.width, src.height, false));
Image::BitmapData dest (newImage, Image::BitmapData::writeOnly);
if (src.pixelStride == dest.pixelStride && src.pixelFormat == dest.pixelFormat)
{
for (int y = 0; y < dest.height; ++y)
memcpy (dest.getLinePointer (y), src.getLinePointer (y), (size_t) dest.lineStride);
}
else
{
for (int y = 0; y < dest.height; ++y)
for (int x = 0; x < dest.width; ++x)
dest.setPixelColour (x, y, src.getPixelColour (x, y));
}
return newImage;
}
示例6: 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));
}
}
}
示例7: 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)
{
//.........这里部分代码省略.........