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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:44:27+00:00 2026-06-13T18:44:27+00:00

I was trying to drawbitmap on a canvas. In the emulator, it seems that

  • 0

I was trying to drawbitmap on a canvas. In the emulator, it seems that the image is blurred. Is it likely that the android automatically scaled the bitmap? I did try to disable the scaling such as

< supports-screens android:smallScreens="false" android:normalScreens="true" 
android:largeScreens="false" android:xlargeScreens="false" android:anyDensity="true" />

blur means if I have a pixel in the bitmap, I am seeing like 2×2 pixel. soemtimes a pixel is missing. so I assumed that Android automatically scaled it to fit different screens. I am just use WVGA and how do I prevent this scaling? Thanks.

  • 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-13T18:44:28+00:00Added an answer on June 13, 2026 at 6:44 pm

    Indeed, both Bitmap and Canvas have a density property, drawing a bitmap automatically scales the bitmap if the densities of the canvas and bitmap differ.

    From Bitmap.setDensity() documentation:

    Specifies the density for this bitmap. When the bitmap is drawn to a
    Canvas that also has a density, it will be scaled appropriately.

    You can call bitmap.setDensity(Bitmap.DENSITY_NONE) to disable this automatic scaling behavior altogether. If you load the bitmap from resources, placing it under drawable-nodpi should be enough.

    For the curious: the logic behind this behavior is implemented in Canvas.cpp (native part of the android.graphics.Canvas), in the drawBitmap__BitmapFFPaint() method:

    static void drawBitmap__BitmapFFPaint(JNIEnv* env, jobject jcanvas,
                                          SkCanvas* canvas, SkBitmap* bitmap,
                                          jfloat left, jfloat top,
                                          SkPaint* paint, jint canvasDensity,
                                          jint screenDensity, jint bitmapDensity) {
        SkScalar left_ = SkFloatToScalar(left);
        SkScalar top_ = SkFloatToScalar(top);
    
        if (canvasDensity == bitmapDensity || canvasDensity == 0
                || bitmapDensity == 0) {
            if (screenDensity != 0 && screenDensity != bitmapDensity) {
                SkPaint filteredPaint;
                if (paint) {
                    filteredPaint = *paint;
                }
                filteredPaint.setFilterBitmap(true);
                canvas->drawBitmap(*bitmap, left_, top_, &filteredPaint);
            } else {
                canvas->drawBitmap(*bitmap, left_, top_, paint);
            }
        } else {
            canvas->save();
            SkScalar scale = SkFloatToScalar(canvasDensity / (float)bitmapDensity);
            canvas->translate(left_, top_);
            canvas->scale(scale, scale);
    
            SkPaint filteredPaint;
            if (paint) {
                filteredPaint = *paint;
            }
            filteredPaint.setFilterBitmap(true);
    
            canvas->drawBitmap(*bitmap, 0, 0, &filteredPaint);
    
            canvas->restore();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to rotate a camera image. The code looks like that: Bitmap result
I have a Canvas I draw on, I'm trying to take the bitmap out,
Im drawing a bitmap at a canvas. Im trying to have this bitmap rotate
i want my bitmap in the center of my screen..i m trying it that
I'm trying to load a bitmap in Android which I want to tile. I'm
I am trying to display an image on a Canvas , but when I
I was trying to make moving bitmap with accelerometer smoother and accidentally noticed that
I am trying to rotate a bitmap when drawing it to a canvas. The
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I am trying to find the best way (preformance-wise) to draw a large Bitmap

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.