本文整理汇总了C++中Filter::applyVerticalScale方法的典型用法代码示例。如果您正苦于以下问题:C++ Filter::applyVerticalScale方法的具体用法?C++ Filter::applyVerticalScale怎么用?C++ Filter::applyVerticalScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::applyVerticalScale方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applySoftware
void FEDropShadow::applySoftware()
{
FilterEffect* in = inputEffect(0);
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
Filter* filter = this->filter();
FloatSize blurRadius(filter->applyHorizontalScale(m_stdX), filter->applyVerticalScale(m_stdY));
FloatSize offset(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
GraphicsContext* resultContext = resultImage->context();
ASSERT(resultContext);
Color color = adaptColorToOperatingColorSpace(m_shadowColor.combineWithAlpha(m_shadowOpacity));
SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(blurRadius.width(), blurRadius.height()));
SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(color.rgb(), SkXfermode::kSrcIn_Mode));
SkPaint paint;
paint.setImageFilter(blurFilter.get());
paint.setColorFilter(colorFilter.get());
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
if (!nativeImage)
return;
resultContext->drawBitmap(nativeImage->bitmap(), drawingRegion.x() + offset.width(), drawingRegion.y() + offset.height(), &paint);
resultContext->drawBitmap(nativeImage->bitmap(), drawingRegion.x(), drawingRegion.y());
}
示例2: apply
void FEDisplacementMap::apply()
{
if (hasResult())
return;
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
in->apply();
in2->apply();
if (!in->hasResult() || !in2->hasResult())
return;
if (m_xChannelSelector == CHANNEL_UNKNOWN || m_yChannelSelector == CHANNEL_UNKNOWN)
return;
ByteArray* dstPixelArray = createPremultipliedImageResult();
if (!dstPixelArray)
return;
IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
RefPtr<ByteArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);
IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
RefPtr<ByteArray> srcPixelArrayB = in2->asUnmultipliedImage(effectBDrawingRect);
ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length());
Filter* filter = this->filter();
IntSize paintSize = absolutePaintRect().size();
float scaleX = filter->applyHorizontalScale(m_scale / 255);
float scaleY = filter->applyVerticalScale(m_scale / 255);
float scaleAdjustmentX = filter->applyHorizontalScale(0.5f - 0.5f * m_scale);
float scaleAdjustmentY = filter->applyVerticalScale(0.5f - 0.5f * m_scale);
int stride = paintSize.width() * 4;
for (int y = 0; y < paintSize.height(); ++y) {
int line = y * stride;
for (int x = 0; x < paintSize.width(); ++x) {
int dstIndex = line + x * 4;
int srcX = x + static_cast<int>(scaleX * srcPixelArrayB->get(dstIndex + m_xChannelSelector - 1) + scaleAdjustmentX);
int srcY = y + static_cast<int>(scaleY * srcPixelArrayB->get(dstIndex + m_yChannelSelector - 1) + scaleAdjustmentY);
for (unsigned channel = 0; channel < 4; ++channel) {
if (srcX < 0 || srcX >= paintSize.width() || srcY < 0 || srcY >= paintSize.height())
dstPixelArray->set(dstIndex + channel, static_cast<unsigned char>(0));
else {
unsigned char pixelValue = srcPixelArrayA->get(srcY * stride + srcX * 4 + channel);
dstPixelArray->set(dstIndex + channel, pixelValue);
}
}
}
}
}
示例3: determineAbsolutePaintRect
void FEDropShadow::determineAbsolutePaintRect()
{
Filter* filter = this->filter();
ASSERT(filter);
FloatRect absolutePaintRect = inputEffect(0)->absolutePaintRect();
FloatRect absoluteOffsetPaintRect(absolutePaintRect);
absoluteOffsetPaintRect.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
absolutePaintRect.unite(absoluteOffsetPaintRect);
unsigned kernelSizeX = 0;
unsigned kernelSizeY = 0;
FEGaussianBlur::calculateKernelSize(filter, kernelSizeX, kernelSizeY, m_stdX, m_stdY);
// We take the half kernel size and multiply it with three, because we run box blur three times.
absolutePaintRect.inflateX(3 * kernelSizeX * 0.5f);
absolutePaintRect.inflateY(3 * kernelSizeY * 0.5f);
if (clipsToBounds())
absolutePaintRect.intersect(maxEffectRect());
else
absolutePaintRect.unite(maxEffectRect());
setAbsolutePaintRect(enclosingIntRect(absolutePaintRect));
}
示例4: platformApplySoftware
void FEMorphology::platformApplySoftware()
{
FilterEffect* in = inputEffect(0);
ByteArray* dstPixelArray = createPremultipliedImageResult();
if (!dstPixelArray)
return;
setIsAlphaImage(in->isAlphaImage());
if (m_radiusX <= 0 || m_radiusY <= 0) {
dstPixelArray->clear();
return;
}
Filter* filter = this->filter();
int radiusX = static_cast<int>(floorf(filter->applyHorizontalScale(m_radiusX)));
int radiusY = static_cast<int>(floorf(filter->applyVerticalScale(m_radiusY)));
IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
RefPtr<ByteArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect);
PaintingData paintingData;
paintingData.srcPixelArray = srcPixelArray.get();
paintingData.dstPixelArray = dstPixelArray;
paintingData.width = effectDrawingRect.width();
paintingData.height = effectDrawingRect.height();
paintingData.radiusX = min(effectDrawingRect.width() - 1, radiusX);
paintingData.radiusY = min(effectDrawingRect.height() - 1, radiusY);
platformApply(&paintingData);
}
示例5: determineAbsolutePaintRect
void FEOffset::determineAbsolutePaintRect()
{
FloatRect paintRect = inputEffect(0)->absolutePaintRect();
Filter* filter = this->filter();
paintRect.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
paintRect.intersect(maxEffectRect());
setAbsolutePaintRect(enclosingIntRect(paintRect));
}
示例6: determineAbsolutePaintRect
void FEMorphology::determineAbsolutePaintRect()
{
FloatRect paintRect = inputEffect(0)->absolutePaintRect();
Filter* filter = this->filter();
paintRect.inflateX(filter->applyHorizontalScale(m_radiusX));
paintRect.inflateY(filter->applyVerticalScale(m_radiusY));
paintRect.intersect(maxEffectRect());
setAbsolutePaintRect(enclosingIntRect(paintRect));
}
示例7: Make
sk_sp<SkImageFilter> FEOffset::createImageFilter() {
Filter* filter = this->getFilter();
SkImageFilter::CropRect cropRect = getCropRect();
return SkOffsetImageFilter::Make(
SkFloatToScalar(filter->applyHorizontalScale(m_dx)),
SkFloatToScalar(filter->applyVerticalScale(m_dy)),
SkiaImageFilterBuilder::build(inputEffect(0), operatingColorSpace()),
&cropRect);
}
示例8: mapRect
FloatRect FEDropShadow::mapRect(const FloatRect& rect, bool forward)
{
FloatRect result = rect;
Filter* filter = this->filter();
ASSERT(filter);
FloatRect offsetRect = rect;
if (forward)
offsetRect.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
else
offsetRect.move(-filter->applyHorizontalScale(m_dx), -filter->applyVerticalScale(m_dy));
result.unite(offsetRect);
IntSize kernelSize = FEGaussianBlur::calculateKernelSize(filter, FloatPoint(m_stdX, m_stdY));
// We take the half kernel size and multiply it with three, because we run box blur three times.
result.inflateX(3 * kernelSize.width() * 0.5f);
result.inflateY(3 * kernelSize.height() * 0.5f);
return result;
}
示例9: platformApplySoftware
void FEDropShadow::platformApplySoftware()
{
FilterEffect* in = inputEffect(0);
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
Filter* filter = this->filter();
FloatSize blurRadius(filter->applyHorizontalScale(m_stdX), filter->applyVerticalScale(m_stdY));
FloatSize offset(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
FloatRect drawingRegionWithOffset(drawingRegion);
drawingRegionWithOffset.move(offset);
ImageBuffer* sourceImage = in->asImageBuffer();
ASSERT(sourceImage);
GraphicsContext* resultContext = resultImage->context();
ASSERT(resultContext);
resultContext->setAlpha(m_shadowOpacity);
resultContext->drawImageBuffer(sourceImage, ColorSpaceDeviceRGB, drawingRegionWithOffset);
resultContext->setAlpha(1);
ShadowBlur contextShadow(blurRadius, offset, m_shadowColor, ColorSpaceDeviceRGB);
// TODO: Direct pixel access to ImageBuffer would avoid copying the ImageData.
IntRect shadowArea(IntPoint(), resultImage->internalSize());
RefPtr<Uint8ClampedArray> srcPixelArray = resultImage->getPremultipliedImageData(shadowArea);
contextShadow.blurLayerImage(srcPixelArray->data(), shadowArea.size(), 4 * shadowArea.size().width());
resultImage->putByteArray(Premultiplied, srcPixelArray.get(), shadowArea.size(), shadowArea, IntPoint());
resultContext->setCompositeOperation(CompositeSourceIn);
resultContext->fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), m_shadowColor, ColorSpaceDeviceRGB);
resultContext->setCompositeOperation(CompositeDestinationOver);
resultImage->context()->drawImageBuffer(sourceImage, ColorSpaceDeviceRGB, drawingRegion);
}
示例10: applySoftware
void FEOffset::applySoftware()
{
FilterEffect* in = inputEffect(0);
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
setIsAlphaImage(in->isAlphaImage());
FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
Filter* filter = this->filter();
drawingRegion.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy));
resultImage->context()->drawImageBuffer(in->asImageBuffer(), drawingRegion);
}
示例11: applySoftware
void FEDisplacementMap::applySoftware()
{
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
ASSERT(m_xChannelSelector != CHANNEL_UNKNOWN);
ASSERT(m_yChannelSelector != CHANNEL_UNKNOWN);
Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult();
if (!dstPixelArray)
return;
IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);
IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asUnmultipliedImage(effectBDrawingRect);
ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length());
Filter* filter = this->filter();
IntSize paintSize = absolutePaintRect().size();
float scaleX = filter->applyHorizontalScale(m_scale);
float scaleY = filter->applyVerticalScale(m_scale);
float scaleForColorX = scaleX / 255.0;
float scaleForColorY = scaleY / 255.0;
float scaledOffsetX = 0.5 - scaleX * 0.5;
float scaledOffsetY = 0.5 - scaleY * 0.5;
int stride = paintSize.width() * 4;
for (int y = 0; y < paintSize.height(); ++y) {
int line = y * stride;
for (int x = 0; x < paintSize.width(); ++x) {
int dstIndex = line + x * 4;
int srcX = x + static_cast<int>(scaleForColorX * srcPixelArrayB->item(dstIndex + m_xChannelSelector - 1) + scaledOffsetX);
int srcY = y + static_cast<int>(scaleForColorY * srcPixelArrayB->item(dstIndex + m_yChannelSelector - 1) + scaledOffsetY);
for (unsigned channel = 0; channel < 4; ++channel) {
if (srcX < 0 || srcX >= paintSize.width() || srcY < 0 || srcY >= paintSize.height()) {
dstPixelArray->set(dstIndex + channel, static_cast<unsigned char>(0));
} else {
unsigned char pixelValue = srcPixelArrayA->item(srcY * stride + srcX * 4 + channel);
dstPixelArray->set(dstIndex + channel, pixelValue);
}
}
}
}
}
示例12: adoptRef
PassRefPtr<SkImageFilter> FEOffset::createImageFilter(SkiaImageFilterBuilder* builder)
{
RefPtr<SkImageFilter> input(builder->build(inputEffect(0), operatingColorSpace()));
Filter* filter = this->filter();
SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
return adoptRef(SkOffsetImageFilter::Create(SkFloatToScalar(filter->applyHorizontalScale(m_dx)), SkFloatToScalar(filter->applyVerticalScale(m_dy)), input.get(), &cropRect));
}
示例13: calculateKernelSize
IntSize FEGaussianBlur::calculateKernelSize(const Filter& filter, const FloatPoint& stdDeviation)
{
FloatPoint stdFilterScaled(filter.applyHorizontalScale(stdDeviation.x()), filter.applyVerticalScale(stdDeviation.y()));
return calculateUnscaledKernelSize(stdFilterScaled);
}