Connect to the SQL database with Dreamweaver MX 2004

Source: Internet
Author: User

Note: The mouse has a moderate level of English. It may be difficult to write local translation (or not translate), but I hope you can learn something from this article: Haha. I hope you can correct the mistakes. For the PNG encoding mode, search for the PNG encoding in AS3 on the search engine! Author: kaourantin.net
I hope you have already used AS3-a strong programming language! As the advertisement word says: "Everything is possible." for AS3, this is true: especially when we come into contact with new classes, such as ByteArray and new data types, such as UINT and INT. This article provides a specific example for these features. The code of the program is not completely compiled by me. I just fixed some bugs in the original program. This is a pure PNG encoding tool, but we can feel that it can bring us powerful features: we only need to input a bitmapdata, the program will return bytes of PNG encoded data for us. Next we can do more, for example, transfer to our server for image processing. We used to compress the cumbersome data through zlib. Now, for AS3, this is really just a piece of cake!

The usage of this class is as follows. You only need to create a BitMapData class and use this class in the following ways:


Var myPNG: ByteArray = PNGEnc. encode (myBitmapData );

How about it! Is it very simple? Of course. We can make it work better through inheritance ~ Let's take a look at the class code to complete these jobs:


Import flash. geom .*;
Import flash. display .*;
Import flash. util .*;
Public class PNGEnc
{
Public static function encode (img: BitmapData): ByteArray
  {
// Create ByteArray data for output
Var png: ByteArray = new ByteArray ();
// Write the PNG header file
Png. writeUnsignedInt (0x89504e47 );
Png. writeUnsignedInt (0x0D0A1A0A );
// Create an IHDR data block
Var IHDR: ByteArray = new ByteArray ();
IHDR. writeInt (img. width );
IHDR. writeInt (img. height );
IHDR. writeUnsignedInt (0x08060000 );
// 32-bit RGBA processing
IHDR. writeByte (0 );
WriteChunk (png, 0x49484452, IHDR );
// Create an IDAT data block
Var IDAT: ByteArray = new ByteArray ();
For (var I: int = 0; I     {
// No filter
IDAT. writeByte (0 );
Var p: uint;
If (! Img. transparent)
        {
& Nbsp
<

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.