#include "SkCanvas.h" #include "SkPaint.h" #include "SkImageFilter.h" #include "SkBlurImageFilter.h" void ApplyGaussianBlur(SkCanvas* canvas, SkBitmap bitmap, float radius, SkPaint paint) { SkImageFilter* blurFilter = SkBlurImageFilter::Make(radius, radius, nullptr); SkPaint filteredPaint(paint); filteredPaint.setImageFilter(blurFilter); canvas->drawBitmap(bitmap, 0, 0, &filteredPaint); }
#include "SkCanvas.h" #include "SkPaint.h" #include "SkImageFilter.h" #include "SkColorMatrixFilter.h" void ApplySepiaFilter(SkCanvas* canvas, SkBitmap bitmap, SkPaint paint) { static const float kSepia[] = { 0.393f, 0.769f, 0.189f, 0.0f, 0.349f, 0.686f, 0.168f, 0.0f, 0.272f, 0.534f, 0.131f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, }; SkColorMatrix sepiaMatrix(kSepia); SkImageFilter* colorFilter = SkColorMatrixFilter::Make(sepiaMatrix); SkPaint filteredPaint(paint); filteredPaint.setImageFilter(colorFilter); canvas->drawBitmap(bitmap, 0, 0, &filteredPaint); }Package Library: The SkPaint getImageFilter method is part of the Skia Graphics Library. Skia is an open-source graphics library that is used in many popular applications, including Google Chrome, Firefox, and Adobe's Creative Cloud. Skia is maintained by Google and is available under a BSD-style license.