SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); bitmap.allocPixels();
SkBitmap srcBitmap; SkBitmap dstBitmap; srcBitmap.readFromFile("input.jpg"); SkBitmap::AllocN32Pixels(srcBitmap.width(), srcBitmap.height(), SkAlphaType::kOpaque_SkAlphaType, &dstBitmap); SkCanvas canvas(dstBitmap); canvas.drawImage(srcBitmap, 0, 0); dstBitmap.writeToFile("output.png", SkEncodedImageFormat::kPNG, 100);In this example, we read an image file called "input.jpg" into an SkBitmap instance named srcBitmap. We then create a new SkBitmap instance named dstBitmap with the same size as the source bitmap. We then create an SkCanvas instance using the destination bitmap and draw the source bitmap onto it. Finally, we write the resulting image to a PNG file called "output.png". Package library: Skia Graphics Library.