用Dreamweaver MX 2004与SQL数据库相连
注:耗子英语水平一般,可能有写地方翻译(或许称不上翻译)的驴唇不对马嘴,但是希望大家能从这篇文章中学到一点东西:)呵呵。有纰漏的地方希望大家指正。关于PNG的编码模式,请大家自己在搜索引擎上进行查找AS3中的PNG编码! 作者:kaourantin.net 我希望
注:耗子英语水平一般,可能有写地方翻译(或许称不上翻译)的驴唇不对马嘴,但是希望大家能从这篇文章中学到一点东西:)呵呵。有纰漏的地方希望大家指正。关于PNG的编码模式,请大家自己在搜索引擎上进行查找AS3中的PNG编码! 作者:kaourantin.net
我希望各位已经使用过了AS3――给我带来了强烈震撼的编程语言!就象广告词中说的一样:“一切皆有可能”;对AS3来讲,真的是这样:)特别是在我们接触到新的类,比如ByteArray 和新的数据类型,比如UINT、INT。本文为这些特性提供了一个具体的实例,程序的代码并不完全是我所编写的,我只是修正了原来程序中的一些BUG。这是一个单纯的PNG编码工具,但我们可以感受到它能为我们带来的强大功能:我们只需要输入一个bitmapdata数据,程序会为我们返回已经进行完PNG编码的ByteArray数据。接下来我们可以做的更多,比如传送到我们的服务器,进行图片处理。原来我们要通过zlib进行烦琐的数据压缩,而现在,对AS3来说,这真的只是小菜一碟!
这个类的具体用法如下,你只需要建立一个BitMapData类,然后通过以下方式使用本类就可以了:
var myPNG:ByteArray = PNGEnc.encode(myBitmapData);
怎么样!非常简单吧?当然。我们可以通过继承使它工作的更好~那么让我们一起来看一下完成这些工作的类代码:
import flash.geom.*;
import flash.display.*;
import flash.util.*;
public class PNGEnc
{
public static function encode(img:BitmapData):ByteArray
{
// 建立输出用ByteArray类型数据
var png:ByteArray = new ByteArray();
//写入PNG头文件
png.writeUnsignedInt(0x89504e47);
png.writeUnsignedInt(0x0D0A1A0A);
// 建立IHDR数据块
var IHDR:ByteArray = new ByteArray();
IHDR.writeInt(img.width);
IHDR.writeInt(img.height);
IHDR.writeUnsignedInt(0x08060000);
// 32位RGBA的处理
IHDR.writeByte(0);
writeChunk(png,0x49484452,IHDR);
// 建立IDAT数据块
var IDAT:ByteArray= new ByteArray();
for(var i:int=0;i {
// no filter
IDAT.writeByte(0);
var p:uint;
if ( !img.transparent )
{
for(var j:int=0;j {
p = img.getPixel(j,i);
IDAT.writeUnsignedInt(uint(((p&0xFFFFFF) }
} else {
for(var j:int=0;j {
p = img.getPixel32(j,i);
IDAT.writeUnsignedInt( uint(((p&0xFFFFFF) }
}
}
IDAT.compress();
writeChunk(png,0x49444154,IDAT);
// 建立IEND数据块
writeChunk(png,0x49454E44,null);
// 返回PNG
return png;
}
private static var crcTable:Array;
private static var crcTableComputed:Boolean = false;
private static function writeChunk(png:ByteArray, type:uint, data:ByteArray)
{
if (!crcTableComputed)
{
crcTableComputed = true;
crcTable = [];
for (var n:uint = 0;n {
var c:uint = n;
for (var k:uint = 0;k {
if (c & 1)
{
c = uint(uint(0xedb88320)^uint(c >>> 1));
} else {
c = uint(c >>> 1);
}
}
crcTable[n] = c;
}
}
var len:uint = 0;
if (data != null)
{
len = data.length;
}
png.writeUnsignedInt(len);
var p:uint = png.position;
png.writeUnsignedInt(type);
if ( data != null )
{
png.writeBytes(data);
}
var e:uint = png.position;
png.position = p;
var c:uint = 0xffffffff;
for (var i:int = 0;i {
c = uint(crcTable[(c ^ png.readUnsignedByte())&uint(0xff)] ^ uint(c >>> 8));
}
c = uint(c^uint(0xffffffff));
png.position = e;
png.writeUnsignedInt(c);
}
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

Use the DataAccessObjects (DAO) library in C++ to connect and operate the database, including establishing database connections, executing SQL queries, inserting new records and updating existing records. The specific steps are: 1. Include necessary library statements; 2. Open the database file; 3. Create a Recordset object to execute SQL queries or manipulate data; 4. Traverse the results or update records according to specific needs.

PHP database connection guide: MySQL: Install the MySQLi extension and create a connection (servername, username, password, dbname). PostgreSQL: Install the PgSQL extension and create a connection (host, dbname, user, password). Oracle: Install the OracleOCI8 extension and create a connection (servername, username, password). Practical case: Obtain MySQL data, PostgreSQL query, OracleOCI8 update record.

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.
