Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




PNG Decoder



Hello everybody, this is my first post here, but I have been looking these forums for a while.Here is my first attempt at decoding images. This is a small class that can decode bytearrays from png images and transfrom that bytearray to a bitmapdata. It is very limited right now, it can only decode truecolour with alpha png images with no interlacing, no filter, and bit depth of 8.The reason I did this was to avoid using the Loader.loadBytes() method, since I needed a faster way to load lots of small png images at the same time that are read by Flash as raw bytes.If you have any suggestions, please let me know.



KirupaForum > Talk > Source/Experiments
Posted on: 11-09-2007, 07:16 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Sorensen H.263 Codec Decoder And On2 VP6 Decoder
Hi All,
Can anybody please, provide me with some pointers for free (C/C++) implementation of "Sorensen H.263" and "On2 VP6" codec decoder.

Also, if instead, you know of any good precise document of how the decoder for this two codecs can be implemented, that will also do.

Happy New Year, 2009 to all.

Thanks.

Swf Decoder ...
Hi to all members of http://www.kirupa.com i jsut want to know ... i hear there is a freeware that can DECODE a SWF file is that true? If it is can i know what is it and where can i download it? Thanx

Swf Decoder ...
Hi to all members of http://www.kirupa.com i jsut want to know ... i hear there is a freeware that can DECODE a SWF file is that true? If it is can i know what is it and where can i download it? Thanx

Jpeg Decoder
Hello,

I have an application where I load 10 quite large jpeg images (about 2000x2000 pixels) as BitmapData. On disk they are not so big, about 100k each but when loaded as bitmap data they consume quite a lot of memory. I only need one of the images at a time, but I need them all in memory in order to switch quickly. I wounder if it is possible somehow to load the images and keep them compressed in memory and tell flash when to decompress them? I have found a Jpeg encoder in as3corelib, but does anyone know of a jpeg decoder? Any other ideas?

Thanks in advance!

FMX Need MRNA Decoder Help
Im trying to make mRNA codon to Amino acid decoder. One that would read, for instance, "UUG UAA" and give you "Leucine STOP". I've been able to create a program that can convert single codons. But can not handle multiple, and only takes the last value.

So if I typed "UUG UAA" it would give me STOP. My current code looks like this:

function onClick(Decode) {
mRNAcodon.text = mRNAcodon.text.toUpperCase();
if (mRNAcodon.text.indexOf("UUU") != -1) {
_root.Amino.text = "Phenylalanine";
} (mRNAcodon.text.indexOf("UUC") != -1) {
_root.Amino.text = "Phenylalanine";
} if (mRNAcodon.text.indexOf("UUA") != -1) {
_root.Amino.text = "Leucine";
} if (mRNAcodon.text.indexOf("UUG") != -1) {
_root.Amino.text = "Leucine";
} if (mRNAcodon.text.indexOf("UCU") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UCA") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UCC") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UCG") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UAU") != -1) {
_root.Amino.text = "Tyrosine";
} if (mRNAcodon.text.indexOf("UAC") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UAA") != -1) {
_root.Amino.text = "STOP";
}
}
(code continues for another 120 lines)
-mRNAcodon is an input box
-Amino is a dynamic text box
-decode is push button

also note that there are 64 combinations of mRNA codons

Now I've been unable to get this code so that when I type more then one 3 character codon "UAC UAA" that it doesnt just give me one result of "STOP"

I need a code will stack it so that if I type "UAC UAA" and hit decode it gives me "Serine STOP"

If you have anything pointing me in the right direction or think you can give me the code. Please post here or Email me at ZionOfRage@netscape.net
Thanks

FMX Need MRNA Decoder Help
Im trying to make mRNA codon to Amino acid decoder. One that would read, for instance, "UUG UAA" and give you "Leucine STOP". I've been able to create a program that can convert single codons. But can not handle multiple, and only takes the last value.

So if I typed "UUG UAA" it would give me STOP. My current code looks like this:

function onClick(Decode) {
mRNAcodon.text = mRNAcodon.text.toUpperCase();
if (mRNAcodon.text.indexOf("UUU") != -1) {
_root.Amino.text = "Phenylalanine";
} (mRNAcodon.text.indexOf("UUC") != -1) {
_root.Amino.text = "Phenylalanine";
} if (mRNAcodon.text.indexOf("UUA") != -1) {
_root.Amino.text = "Leucine";
} if (mRNAcodon.text.indexOf("UUG") != -1) {
_root.Amino.text = "Leucine";
} if (mRNAcodon.text.indexOf("UCU") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UCA") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UCC") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UCG") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UAU") != -1) {
_root.Amino.text = "Tyrosine";
} if (mRNAcodon.text.indexOf("UAC") != -1) {
_root.Amino.text = "Serine";
} if (mRNAcodon.text.indexOf("UAA") != -1) {
_root.Amino.text = "STOP";
}
}
(code continues for another 120 lines)
-mRNAcodon is an input box
-Amino is a dynamic text box
-decode is push button

also note that there are 64 combinations of mRNA codons

Now I've been unable to get this code so that when I type more then one 3 character codon "UAC UAA" that it doesnt just give me one result of "STOP"

I need a code will stack it so that if I type "UAC UAA" and hit decode it gives me "Serine STOP"

If you have anything pointing me in the right direction or think you can give me the code. Please post here or Email me at ZionOfRage@netscape.net
Thanks

Text Encoder/Decoder
Is it possible to create an application in flash that will take what you type in an an input field and encode/decode the text based on whether a = 5 or a= r or whatever (Maybe like a Caesar Cipher). I just want to create a fun little app for my kids to send secret messages.

JPEG Decoder (viewer) - Optimization
Intro
I write this as both a very simplistic guide to the creation of a JPEG decoder in flash and a request for help. My preemptive apologies if this is somewhat leech-like - hopefully others will be able to use the class (it averts the memory-leak exhibited by the Loader object).

Background
I wrote this class to try and avoid, as I previously mentioned, the memory-leak exhibited by the Loader object. It works exclusively with JPEG images atm and currently only those exported-for-web through photoshop (with quality = 90). The latter limitations do not concern me, I'm quite capable of circumventing them.

Unfortunately however, the majority of JPEG viewers use optimized iDCT algorithms which I've not yet being able to implement.

Optimization (Request for help)
The class loads an image very slowly this is due to two functions:jpgImgDecodeScanData - I believe the delay caused by this procedure to be due to the manner in which it searches for codes in the scan data and compares them to huffman tables. Currently it iterates through the huffman entires, (in ascending order), until it locates a valid code.
idct - this requires an optimized algorithm.
Any input would be greatly appreciated.

License
Reuse of the provide code is more than welcomed under the GNU license.

Pertinent Code

Code:
private function jpgImgDecodeScanData():Boolean
{
var tabInd:int = 0;
var dc:Boolean = true;
var type:String = 'L';
var ind:int = 0;
var indMCU:int = 0;
var htInd:Array;
var val:int;
imgMCU = new Array();

// process scan data
for (var k:int = 0;k < imgSCAN.length; k++)
{
var code:int = -1;
var strByt:String;

// find code
for (var i:int = 0;i < imgDT[tabInd]["code"].length; i++)
{
// validate
if (imgDT[tabInd]["code"][i].length > 0)
{
// generate string
strByt = imgSCAN.substr(ind, i+1);
//trace("ind: " + ind + ' - len: ' + (i+1) + ' txt: ' + strByt);

// check against codes
for (var j:int = 0; j < imgDT[tabInd]["code"][i].length; j++)
{
if (strByt == imgDT[tabInd]["code"][i][j])
{
code = Number(imgDT[tabInd]["bit"][i][j]);
//trace(code + "' = '" + strByt + "'");
break;
}
}

// completion
if (code >= 0) break;
}
}

// completion
if (code < 0)
{
//trigEvent(customEvent.ERROR, customEvent.ERR_IMG_MISC, 'invalid scan segment');
//return false;
return true;
}

// advance
ind += strByt.length;

// process based on type
if (dc)
{
// dc-value
// initialize mcu
if (imgMCU[indMCU] == null) imgMCU[indMCU] = new Array();
imgMCU[indMCU][type] = new Array();
imgMCU[indMCU][type]['dat'] = new Array();

// retrieve value
val = Number(procedures.bas2bas(imgSCAN.substr(ind, code), 10, 2));

// decode dc value
if (val < Math.pow(2, code)/2) val = ((Math.pow(2, code) - 1) - val) * -1;
if (indMCU > 0) val += imgMCU[indMCU-1][type]['dat'][0];
imgMCU[indMCU][type]['dat'][0] = val;
//trace('DC for ' + type + ' = ' + val);

// update status
if (type=='L') tabInd = 2; else tabInd = 3;
htInd = new Array();
dc = false;

// advance position
ind += code;
} else {
// ac-value
// record ac value
var indAC:int = imgMCU[indMCU][type]['dat'].length;
var strNib:String = procedures.bytPad(procedures.bas2bas(String(code)));
var zrl:int = Number(procedures.bas2bas(strNib.substr(0, 4), 10, 2));
var readLen:int = Number(procedures.bas2bas(strNib.substr(4, 4), 10, 2));
var strVal:String = imgSCAN.substr(ind, readLen);

// determine value
val = Number(procedures.bas2bas(strVal, 10, 2));
if (strVal.charAt(0) == '0') val = (Math.pow(2, strVal.length) - 1) * -1 + val;

//trace('readLen: ' + readLen + ', zrl: ' + zrl + ', val: ' + val);
if (indAC==0) trace("key: " + type + ',val: ' + val);

// propagate zero run-length
for (var q:int=0;q<zrl;q++)
{
imgMCU[indMCU][type]['dat'][indAC++] = '0';
}

// retrieve nibbles (RLC)
imgMCU[indMCU][type]['dat'][indAC] = val;
//trace("compiled byte: " + strNib + ", category: " + cat + ", category code: " + catCode);

// mcu completion
if (code == 0 || indAC == 63)
{
//trace("found EOB");
// update status
dc = true;
if (type=='L' || type == 'B')
{
if (type == 'L') type = 'B'; else type = 'R';
tabInd = 1;
} else {
// new mcu
indMCU++;
type = 'L';
tabInd = 0;
}
}

// advance position
ind += readLen;
}
}

return true;
}



private function idct(dat:Array):Array {
var u,v,xx,yy:int;
var temp:Array = new Array();
for (xx=0; xx<8; xx++) {
temp[xx] = new Array();
for (yy=0; yy<8; yy++) {
temp[xx][yy] = 0;
for (u=0; u<8; u++) {
for (v=0; v<8; v++) {
if (dat[u*8+v]==null) dat[u*8+v] = 0;
var val:Number = dat[u*8+v] * Math.cos((2*xx+1)*u*Math.PI/16.0) * Math.cos((2*yy+1)*v*Math.PI/16.0);
if (u==0) val *= .7071;
if (v==0) val *= .7071;
temp[xx][yy] += val;
}
}
}
}

for (xx=0; xx<8; xx++) {
for (yy=0; yy<8; yy++) {
dat[xx*8+yy] = Math.floor(temp[xx][yy] / 4 + 0.5);
}
}

return dat;
}
Useful Links
These are probably more helpful for those looking to develop their own JPEG viewer / encoder (the latter of which has already been achieved).
ImperialViolet Haskell Sample Code / Tutorial
ImpulseAdventure - JPEG huffman Coding tutorial

Sample Image
Please find sample images attached below.

Once again help, however minimal, is greatly appreciated

Decoder Text Effect Not Working
hiya all,
Heres an example of a decoder text i need working, but it only works in flash player 6, not 8. can anyone see why?

http://www.actionscript.org/showMovie.php?id=1227

Creating A Flash Message Encoder/decoder
I'm trying to design a flash program that a person could type in a message into a form, then click a button and it would convert the message into a "secret code" and back again? Any suggestions

Creating A Flash Message Encoder/decoder
Quick Question:

I want to design a little flash program that you type in a message and click a "encode" button and it "codes" the message and can also "decode"

*I guess what I'm wanting to know if you can say type "secret" into a form and click a button and the form now displays something like this: "etietp" - basically this is "secret" in a code. Is there a way to do it? To where someone could type/paste a message into the form and decode it based on a certain "code".


Thanks

Copyright © 2005-08 www.BigResource.com, All rights reserved