IntSize dragImageSize(DragImageRef image) { if (!image) return IntSize(); return IntSize(image->width(), image->height()); }
DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) { if (!image) return 0; int scaledWidth = image->width() * scale.width(); int scaledHeight = image->height() * scale.height(); *image = image->scaled(scaledWidth, scaledHeight); return image; }
DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) { if (!image) return 0; int imageWidth = scale.width() * image->width(); int imageHeight = scale.height() * image->height(); DragImageRef scaledImage = new SkBitmap( skia::ImageOperations::Resize(*image, skia::ImageOperations::RESIZE_LANCZOS3, imageWidth, imageHeight)); delete image; return scaledImage; }
DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction) { if (!image) return 0; image->setIsOpaque(false); image->lockPixels(); for (int row = 0; row < image->height(); ++row) { for (int column = 0; column < image->width(); ++column) { uint32_t* pixel = image->getAddr32(column, row); *pixel = SkPreMultiplyARGB(SkColorGetA(*pixel) * fraction, SkColorGetR(*pixel), SkColorGetG(*pixel), SkColorGetB(*pixel)); } } image->unlockPixels(); return image; }