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

  • Home
  • SEARCH
  • 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 8257853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:20:31+00:00 2026-06-08T02:20:31+00:00

I save an image in a String, then when I open it it’s always

  • 0

I save an image in a String, then when I open it it’s always 300×150

Why is the image truncated?

Where does 300×150 come from?

The code is what you see. Just 2 buttons.

The first one saves the image in “png”, and the other reads the image from “png”

                    Button save = new Button("copy");
                    save.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            ImageElement imageElement = ImageElement.as(image.getElement());

                            Canvas canvasTmp = Canvas.createIfSupported();
                            Context2d context = canvasTmp.getContext2d();
                            context.drawImage(imageElement, 0.0, 0.0, imageElement.getWidth(), imageElement.getHeight());
                            png = canvasTmp.toDataUrl("image/png");
                        }
                    });

                    Button open = new Button("open");
                    open.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {

                            final Image image = new Image(png);
                            vp.add(image);
                            image.addLoadHandler(new LoadHandler() {

                                @Override
                                public void onLoad(LoadEvent event) 
                                {
                                    Window.alert("ok");
                                }
                            });

                            image.addErrorHandler(new ErrorHandler() {

                                @Override
                                public void onError(ErrorEvent event) {
                                    Window.alert("error");
                                }
                            } );

                        }
                    });
  • 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-06-08T02:20:33+00:00Added an answer on June 8, 2026 at 2:20 am

    The canvas has a default width of 300 pixels and a default height of 150 pixels. After creating the canvas and before drawing the image, consider doing this:

    int width = imageElement.getWidth()
    int height = imageElement.getHeight()
    canvasTmp.setWidth(width + "px");
    canvasTmp.setHeight(height + "px");
    canvasTmp.setCoordinateSpaceWidth(width);
    canvasTmp.setCoordinateSpaceHeight(height);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following code is to save image took from camera into photo album. if ([mediaType
i have created one image but problem is that when i save image from
I have written code in Java to access web cam,and to save image... I
I'm trying to save and then load the files that I've just saved but
I'm loading an image file from a web server, and then saving it to
I need to save images in certain folder of my application: string path=E:\AJAXEnabledWebSite1\images\gallery I
From the MongoDB manual: By default, all database strings are UTF8. To save images,
I can save image to iPhone (iPhone Photo Albums \ Saved Photos) with UIImageWriteToSavedPhotosAlbum(image,
I want to save Image in Database with JSON web service .without image data
Image Dummy = Image.FromFile(image.png); Dummy.Save(image.bmp, ImageFormat.Bmp); what the question says i have these using

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.