Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1092729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:43:36+00:00 2026-05-16T23:43:36+00:00

I am creating this drawing application, where the user can click preview and it

  • 0

I am creating this “drawing application”, where the user can click “preview” and it will take what they made, draw a bitmap, and then I want to split that bitmap into left and right images. I create the first bitmap, encode it as a jpeg, and then use that to cut the left and right out using copypixels. I then reform the images together with a space inbetween in one canvas, and draw that canvas. Everything works fine up there.

When I go to encode the new bitmap, and then offer it to save out, the saved image is blank. I have tested everything up to that point and it all works fine. I see the images on screen, I can save out the first bitmap fine.. but the second one is always blank. Here is some sample code, possibly someone can help me out.

_mainBmd = new BitmapData(_jacketWidth, _jacketHeight);
_mainBmd.draw(_imageHolder);
startEncode(_mainBmd);


private function startEncode(imageBitmapData:BitmapData):void 
        {
            var encoder:JPEGAsyncEncoder = new JPEGAsyncEncoder(100);
            encoder.PixelsPerIteration = 150;
            encoder.addEventListener(JPEGAsyncCompleteEvent.JPEGASYNC_COMPLETE, encodeDone);

            encoder.encode(imageBitmapData);


        }

private function encodeDone(event:JPEGAsyncCompleteEvent):void
        {

_leftBmd = new BitmapData(sideWidth, sideHeight);
            var lRect:Rectangle = new Rectangle(0,0, sideWidth, sideHeight);
            var lPoint:Point = new Point(0,0);
            _leftBmd.copyPixels(_mainBmd, lRect, lPoint);


            _rightBmd = new BitmapData(sideWidth, sideHeight);
            var bWidth:Number = 200;
            var sWidth:Number = 111;
            var rRectWidth:Number = (bWidth/2 + sWidth) *  Constants.print_dpi;
            var rRect:Rectangle = new Rectangle(rRectWidth, 0, sideWidth, sideHeight);
            var rPoint:Point = new Point(0, 0);
            _rightBmd.copyPixels(_mainBmd, rRect, rPoint);

var lbm:Bitmap = new Bitmap(_leftBmd);
            var rbm:Bitmap = new Bitmap(_rightBmd);

            //now combine the two images into one holder with a space in the middle 


            //left Image
            var l_Image:Image = new Image();
            l_Image.source = lbm;

            //right image
            var r_Image:Image = new Image();
            r_Image.source = rbm;

var newRender:Canvas = new Canvas();
            newRender.clipContent = false;
            newRender.minHeight = 0;
            newRender.minWidth = 0;

            newRender.addChild(l_Image);
            r_Image.x = 500;
            newRender.addChild(r_Image);

fcBMD = new BitmapData(renderW, renderH);
            fcBMD.draw(newRender);

startEncode2(fcBMD);


}

private function startEncode2(imageBitmapData:BitmapData):void 
        {
            var encoder:JPEGAsyncEncoder = new JPEGAsyncEncoder(100);
            encoder.PixelsPerIteration = 150;
            encoder.addEventListener(JPEGAsyncCompleteEvent.JPEGASYNC_COMPLETE, encode2Done);

            encoder.encode(imageBitmapData);


        }

private function encode2Done(event:JPEGAsyncCompleteEvent):void
        {
            _data  = event.ImageData;


        }

private function onSaveRenderClick(e:MouseEvent):void  //save button listener
        {
            var fileRef:FileReference = new FileReference();
            fileRef.addEventListener(Event.SELECT, onSaveComplete);
            fileRef.save(_data, 'testImage.jpg');
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:43:37+00:00Added an answer on May 16, 2026 at 11:43 pm

    Is there a special reason why you go trough all the loops of creating a Canvas holder and adding Images?

    Why not use copyPixels directly on the final BitmapData that you want to encode:

    var backgroundColor:uint = 0xffffff;
    fcBMD = new BitmapData(renderW, renderH, false, backgroundColor);
    
    var lPoint:Point = new Point(0,0);
    var lRect:Rectangle = new Rectangle(0,0, sideWidth, sideHeight);
    fcBMD.copyPixels(_mainBmd, lRect, lPoint);
    
    var rRect:Rectangle = new Rectangle(rRectWidth, 0, sideWidth, sideHeight);
    var rPoint:Point = new Point(renderW - sideWidth, 0);
    fcBMD.copyPixels(_mainBmd, rRect, rPoint);
    
    startEncode2(fcBMD);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked this Can I automate creating a .NET web application in IIS? a
I'm creating an application where I will be drawing two circles onto the screen,
How can I have it so Visual Studio doesn't keep re-creating this folder that
Hello can anybody solve this please I'm creating the object in the action class
I'm creating a simple drawing application that adds new Shape objects to a MovieClip
I am creating a application that store basic database connection info like host,user, password
I'm creating a drawing application with OpenGL. I'v created an algorithm that generates gradient
My original question: I'm creating a simple drawing application and need to be able
I'm creating a small image upload validator for this printing company, they need to
Note: I found this Creating a Word Doc in C#.NET , but that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.