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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:57:21+00:00 2026-06-16T16:57:21+00:00

I am using an activity to display a Full image and user has a

  • 0

I am using an activity to display a Full image and user has a button to save it.

Image is being loaded in imageview from URL where I have hosted image on internet.

I am saving an image as PNG file.

After saving image its quality is reduced. I know PNG is not lossless, but is there any way I can save an image as it is without any compromise with quality or resolution??

Here is the code:

buttonSave.setOnClickListener(new Button.OnClickListener()
{
    public void onClick(View arg0) 
    {
        fullSizeImage.buildDrawingCache();
        Bitmap bm=fullSizeImage.getDrawingCache();
        String root = Environment.getExternalStorageDirectory().toString();
        File myDir = new File(root + File.separator + "MyWallpapers");
        if(!myDir.exists())
        {
            myDir.mkdir();
        }
        String fname = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())+".png";
        File file = new File (myDir, fname);
        /*if (file.exists ()) file.delete (); */
        try 
        {
            //FileOutputStream out = new FileOutputStream(file);
            /*FileOutputStream out = new FileOutputStream(file);

            bm.compress(Bitmap.CompressFormat.PNG, 100, out);*/

            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            bm.compress(Bitmap.CompressFormat.PNG, 100, bytes);

            file.createNewFile();
            //write the bytes in file
            FileOutputStream fo = new FileOutputStream(file);
            fo.write(bytes.toByteArray());
            bytes.flush();
            bytes.close();
            /*out.flush();
            out.close();*/
            Toast.makeText(FullSizeImageDisplay.this, "Wallpaper Saved in SDcard/MyWallpapers folder",Toast.LENGTH_SHORT).show();
            String[] paths = {root + File.separator + "MyWallpapers"};

            String[] mediaType = {"image/png"};
            MediaScannerConnection.scanFile(FullSizeImageDisplay.this, paths, mediaType, null);
            ContentValues values = new ContentValues();
            values.put(MediaStore.Images.Media.DATA, file.getAbsolutePath());
            values.put(MediaStore.Images.Media.MIME_TYPE, "image/png"); 

            getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
        } 
        catch (Exception e) 
        {
            e.printStackTrace();
        }

        OutputStream fOut = null;
        Uri outputFileUri;

        }
    });
}
  • 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-16T16:57:22+00:00Added an answer on June 16, 2026 at 4:57 pm
    fullSizeImage.buildDrawingCache();
    Bitmap bm=fullSizeImage.getDrawingCache();
    

    Where fullSizeImage is may be an Image View.

    I see problem is arising while you load the image. You must have used something like BitmapFactory.Options

    Make following changes

    BitmapFactory.decodeStream(<param1>,param2,null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an image to display via an ImageView element. Based on user input
I Have a Service and i interact with it from an activity using Binding.
I am using Theme.Dialog activity to display user a reminder whenever Alarm triggers, It
I'm using Google's GeoChart to display some activity data I've gathered from an outside
Hi I have an Activity(Activity_1) which calls another Activity(Activity_2) using activity for result. In
I am using an Activity that extends SherlockFragmentActivity , that has 3 tabs. The
I have an Activity A that calls an Activity B using startActivityForResult() . Under
I keep getting the above error, going from my first activity that has a
I want to display listview in my songlist activity,.. For that i have created
I have two activity: MediaPlayer_Activity (display the control like play,pause,stop,next....) MediaPlayerPlayList_Acitivty (to display all

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.