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 6998369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:24:11+00:00 2026-05-27T20:24:11+00:00

A seemingly simple issue, I have an off-screen bitmap that I perform some transformations

  • 0

A seemingly simple issue, I have an off-screen bitmap that I perform some transformations to (rotation, scaling, etc) and I’d like to store a copy of the bitmap prior to the transformations, such that in my View’s onDraw(), I can display the transformed off-screen bitmap AND a smaller scaled version of the un-transformed bitmap as a thumbnail.

No problem writing the off-screen bitmap in onDraw(), but the copied ‘preserved’ bitmap is also being transformed. Here is the code where I am making the copy of the bitmap, where mCanvas was created via mCanvas = new Canvas(mBitmap);:

mPreservedBitmap = Bitmap.createBitmap(mBitmap);

// save the canvas
mCanvas.save();

// do some rotations, scaling
mCanvas.rotate(rotation, px, py);
mCanvas.scale(scaleFactor, scaleFactor, scaleFocusX, scaleFocusY);

// draw the bitmaps to the screen
invalidate();

// restore the bitmap
mCanvas.restore();

In onDraw(), I have:

// draw the off-screen bitmap to the on-screen bitmap
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);

// draw the preserved image, scaling it to a thumbnail first
canvas.drawBitmap(
    Bitmap.createScaledBitmap(mPreservedBitmap, (int) thumbWidth, (int) thumbHeight, true), 
null, 
thumbnailRectF, 
thumbCanvasPaint);

The thumbnail gets scaled to the appropriate size, but the bitmap that is being scaled down to thumbnail size is also rotated and scaled the exact same as mBitmap, which I don’t want. I’ve also tried the Bitmap.copy() method, but with the same results. Any pointers/assitance/advice?

Thanks,

Paul

  • 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-27T20:24:11+00:00Added an answer on May 27, 2026 at 8:24 pm

    My final solution to this was to generate a copy of the canvas Bitmap PRIOR to it being scaled via:

    mPreservedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), null, true);
    

    Then, when the Canvas and the primary Bitmap is scaled, I can draw the non-scaled ‘preserved’ Bitmap to the Canvas in onDraw() via:

    canvas.drawBitmap(mPreservedBitmap, null, thumbnailRectF, thumbCanvasPaint);
    

    Per Romain’s comments above, I scale the preserved Bitmap off-screen to improve performance in onDraw().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a seemingly simple question that I need help with. I have a
A seemingly simple question: Can I have some sort of Number object, which can
I have a seemingly simple problem though i am unable to get my head
I have a seemingly simple problem whereby I wish to reconcile two lists so
I'm trying to do something seemingly simple: ensure that Application_BeginRequest is called for every
I have a seemingly simple requirement, but i can't figure out how to write
I'm attempting to creat a HTML button using JavaScript (seemingly simple), yet for some
I've looked for hours for the answer to this seemingly simple issue I'm having.
I have this seemingly easy issue in FF4. In the code below I need
I have a winform program that does some asynchronous IO on a SerialPort .

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.