• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AS3 BitmapData to Jpeg to SqlLite database to BitmapData

Community Beginner ,
Feb 25, 2015 Feb 25, 2015

Copy link to clipboard

Copied

Hi,

using AS3, for an AIR application, I have a BitmapData object (obtained from webcam shot). I need to compress the image with JPEGEncoder and save it in a SQLLIte database (string?).

And then I need to re-build the BitmapData object using the data stored in the database.

It's importante the passage of the jpeg compression!

Has someone an idea about how to implement this?

THANK YOU IN ADVACE!

TOPICS
ActionScript

Views

582

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2015 Feb 25, 2015

Copy link to clipboard

Copied

the jpegencoder constructor accepts a quality parameter (and you can use the jpegencoderoptions class) to compress the file.

here's more info:  Adobe Flash Platform * Compressing bitmap data

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 25, 2015 Feb 25, 2015

Copy link to clipboard

Copied

Hi, thank you for your reply.

I actually know how to compress an image using JPEGEncoder. What I don't know is how to rebuild the BitmapData starting from the ByteArray obtained by the JPEGEncoder.

Note that I cannot used the UrlLoader, because my jpeg is not stored in the filesystem but in the database (encoding the ByteArray as a String).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2015 Feb 25, 2015

Copy link to clipboard

Copied

then you should probably not use the jpegencoder.

create your own array of pixels that you save and load.  you can compress your data by collapsing same colored adjacent pixels.  in my experience that cuts storage space significantly though it obviously depends on the bitmap.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 26, 2015 Feb 26, 2015

Copy link to clipboard

Copied

Encode the ByteArray from the JPEG encoder to a Base64 string and store that. You can then easily rebuild the JPEG from the string... Just Google Base64 to Jpeg AS3 and you'll find all you need.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 26, 2015 Feb 26, 2015

Copy link to clipboard

Copied

HI dmennenoh,

but after converting the string to byteArray (which represents the Jpeg image), how to convert it in a BitmapData object.

Please, if you could sugest some code, because I've googled a lot, but without finding what I need.

NOTE: I need a synchronous way to trasform the bytearray jpeg to BitmapData.

Thank you very much!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 26, 2015 Feb 26, 2015

Copy link to clipboard

Copied

LATEST

Hmm, I seem to find info right away about this... anyway, look at the setPixels method of BitmapData - should be what you need.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines