SoFunction
Updated on 2025-03-10

Detailed explanation of the method of processing image bitmap operations in Hongmeng Development (Basic Knowledge of HarmonyOS Hongmeng Development)

Bitmap operation development guidance

Graph operation refers to performing related operations on PixelMap images, such as creating, querying information, reading and writing pixel data, etc.

1. Create a bitmap object PixelMap

// Specify initialization options to createPixelMap pixelMap2 = (initializationOptions);
 
// Create from pixel color arrayint[] defaultColors = new int[] {5, 5, 5, 5, 6, 6, 3, 3, 3, 0};
 initializationOptions = new ();
 = new Size(3, 2);
 = PixelFormat.ARGB_8888;
PixelMap pixelMap1 = (defaultColors, initializationOptions);
 
// Create another PixelMap as the data sourcePixelMap pixelMap3 = (pixelMap2, initializationOptions);

2. Get information from the bitmap object.

long capacity = ();
long bytesNumber = ();
int rowBytes = ();
byte[] ninePatchData = ();

3. Read and write bit image pixel data

// Read pixels at the specified locationint color = (new Position(1, 1));
 
// Read pixels in the specified areaint[] pixelArray = new int[50];
Rect region = new Rect(0, 0, 10, 5);
(pixelArray, 0, 10, region);
 
// Read pixels to BufferIntBuffer pixelBuf = (50);
(pixelBuf);
 
// Write pixels at the specified location(new Position(1, 1), 0xFF112233);
 
// Write pixels in the specified area(pixelArray, 0, 10, region);
 
// Write pixels in the Buffer(intBuf);

Summarize

This is the article about the detailed explanation of the method of processing image bitmap operations in Hongmeng Development (Basic Knowledge of HarmonyOS Hongmeng Development). This is the end. For more related contents of Hongmeng Development, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!