asctionscript3 保存jpg格式。





package com.wdxc.util 
... {
    import flash.geom.
*;
    import flash.display.
*
    import flash.utils.
*;
     
    
public class JPGEncoder...{
 
        
// Static table initialization
    
        
private var ZigZag:Array = [
             
0156,14,15,27,28,
             
247,13,16,26,29,42,
             
38,12,17,25,30,41,43,
             
9,11,18,24,31,40,44,53,
            
10,19,23,32,39,45,52,54,
            
20,22,33,38,46,51,55,60,
            
21,34,37,47,50,56,59,61,
            
35,36,48,49,57,58,62,63
        ];
    
        
private var YTable:Array = new Array(64);
        
private var UVTable:Array = new Array(64);
        
private var fdtbl_Y:Array = new Array(64);
        
private var fdtbl_UV:Array = new Array(64);
    
        
private function initQuantTables(sf:int):void
        
...{
            var i:
int;
            var t:Number;
            var YQT:Array 
= [
                
1611101624405161,
                
1212141926586055,
                
1413162440576956,
                
1417222951878062,
                
1822375668,109,10377,
                
2435556481,104,11392,
                
49647887,103,121,120,101,
                
72929598,112,100,10399
            ];
            
for (i = 0; i < 64; i++...{
                t 
= Math.floor((YQT[i]*sf+50)/100);
                
if (t < 1...{
                    t 
= 1;
                }
 else if (t > 255...{
                    t 
= 255;
                }

                YTable[ZigZag[i]] 
= t;
            }

            var UVQT:Array 
= [
                
1718244799999999,
                
1821266699999999,
                
2426569999999999,
                
4766999999999999,
                
9999999999999999,
                
9999999999999999,
                
9999999999999999,
                
9999999999999999
            ];
            
for (i = 0; i < 64; i++...{
                t 
= Math.floor((UVQT[i]*sf+50)/100);
                
if (t < 1...{
                    t 
= 1;
                }
 else if (t > 255...{
                    t 
= 255;
                }

                UVTable[ZigZag[i]] 
= t;
            }

            var aasf:Array 
= [
                
1.01.3870398451.3065629651.175875602,
                
1.00.7856949580.5411961000.275899379
            ];
            i 
= 0;
            
for (var row:int = 0; row < 8; row++)
            
...{
                
for (var col:int = 0; col < 8; col++)
                
...{
                    fdtbl_Y[i]  
= (1.0 / (YTable [ZigZag[i]] * aasf[row] * aasf[col] * 8.0));
                    fdtbl_UV[i] 
= (1.0 / (UVTable[ZigZag[i]] * aasf[row] * aasf[col] * 8.0));
                    i
++;
                }

            }

        }

    
        
private var YDC_HT:Array;
        
private var UVDC_HT:Array;
        
private var YAC_HT:Array;
        
private var UVAC_HT:Array;
    
        
private function computeHuffmanTbl(nrcodes:Array, std_table:Array):Array
        
...{
            var codevalue:
int = 0;
            var pos_in_table:
int = 0;
            var HT:Array 
= new Array();
            
for (var k:int=1; k<=16; k++...{
                
for (var j:int=1; j<=nrcodes[k]; j++...{
                    HT[std_table[pos_in_table]] 
= new BitString();
                    HT[std_table[pos_in_table]].val 
= codevalue;
                    HT[std_table[pos_in_table]].len 
= k;
                    pos_in_table
++;
                    codevalue
++;
                }

                codeval

你可能感兴趣的:(Flash,J#)