I have been looking for a method to process transparent GIF images. At the prompt of jillzhang, I saw an article, one of which explained the conversion of Bitmap. Here I take the core partCodeTake it out for learning and research. I don't know much about image operations, so I don't know much about this code. Please give me some advice.
- Download the code in this article
The author said in the article:
- If you load an 8-bit transparent PNG image into an image, it is converted into a 32-bit image format, and the color palette and transparent information are lost.
- If the 8-bit transparent GIF image is loaded into the image, the image format remains unchanged, and the color palette and transparent information are retained.
- If a four-bit transparent GIF image is loaded into an image, it will be converted into an 8-bit image format, a 16-bit color palette (16 entries palette, 16-bit ?) Will be retained.
- If you use the getthumbnailimage method to scale down an 8-bit transparent GIF image, a 24-bit PNG thumbnail is generated and transparent information is lost.
The author provides a method for zooming and zooming transparent GIF:
- Load the original image into bitmap.
- Create a new bitmap with the scaled size. pixelformat and palette are the same as those of the original image.
- Then, find the original image information at the corresponding position in the target image pixel by pixel.
ProgramIn order to improve efficiency, we will use pointer operations. If you can understand them, please kindly advise. Xie la first. Some code is as follows:
unsafe { byte * P = (< SPAN class = "kwrd"> byte *) ( void *) targetscan0; int noffset = targetstride-scaledbitmap. width; for ( int Y = 0; y
for (
int x = 0; x
byte *) (
int ) sourcescan0 + (
int ) (math. floor (y * yfactor) * sourcestride) + (
int ) math. floor (x * xfactor) [0]; ++ P;} p + = noffset ;}
Because pointers are used, you must set the allow non-secure code during compilation. compileroptions = "/unsafe" must be added to Web. config. Which of the following information about bitmap operations can be shared? Thank you.