Zooming GIF images with transparent colors

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.