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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:56:54+00:00 2026-05-20T18:56:54+00:00

I am resizing image and rotating it using Matrix: Matrix mtx = new Matrix();

  • 0

I am resizing image and rotating it using Matrix:

Matrix mtx = new Matrix();
if(orientation>0) {
    mtx.postRotate(orientation);
    Log.d(TAG,"image rotated: "+orientation);
}
if(scale<1) {
    mtx.postScale(scale,scale);
    Log.d(TAG,"image scaled: "+scale);
}
bmp = Bitmap.createBitmap(bm_orig, 0, 0, width, height, mtx, true);
bm_orig.recycle();
bmp.compress(Bitmap.CompressFormat.JPEG,95,output);
bmp.recycle();

When bmp_orig is taken, used 3.2 Mpx Camera, image resized and rotated looks normal.

But when source is 4 Mpx or bigger, result after resizing has barely-noticeable linear noise

I dont know, why does this noise appear, and how to remove it.

Any idea?
May be another way to resize and rotate?

  • 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-20T18:56:55+00:00Added an answer on May 20, 2026 at 6:56 pm

    Found that this problem is related with source and resulting image size.

    Solved it, when check image size before loading it, and then load halfsized image, if source image size is more than 2 times bigger than resulting size is needed.

    BitmapFactory.Options options_to_get_size = new BitmapFactory.Options();
    options_to_get_size.inJustDecodeBounds = true;
    BitmapFactory.decodeStream(input, null, options_to_get_size);
    int load_scale = 1; // load 100% sized image
    int width_tmp=options_to_get_size.outWidth
    int height_tmp=options_to_get_size.outHeight;
    
    while(width_tmp/2>maxW && height_tmp/2>maxH){
    width_tmp/=2;//load half sized image
    height_tmp/=2;
    load_scale*=2;
    }
    Log.d(TAG,"load inSampleSize: "+ load_scale);
    
    //Now load image with precalculated scale. scale must be power of 2 (1,2,4,8,16...)
    BitmapFactory.Options option_to_load = new BitmapFactory.Options();
    option_to_load.inSampleSize = load_scale;
    ((FileInputStream)input).getChannel().position(0); # reset input stream to read again
    Bitmap bm_orig = BitmapFactory.decodeStream(input,null,option_to_load);
    
    input.close();
    //now you can resize and rotate image using matrix as stated in question
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am resizing an image that is uploaded and I am creating a new
Does anyone know of any good image resizing libraries that will handling resizing large
I'm working on a JavaScript image resizing feature which rely on the IE only
I'm currently running into some issues resizing images using GD. Everything works fine until
I am doing a series of window resizing using the DeferWindowPos functionality. Suppose I
I'm using Codeigniter's image manipulation library to re-size an uploaded image to three sizes,
what I am looking is for a jQuery plugin capable of rotating and resizing
This is driving me crazy, so... When resizing image to small thumbnail, resulting image
The image resizing function provided by Emgu (a .net wrapper for OpenCV) can use
PIL is great for resizing an image 99% of time. But as there are

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.