Change PPI (pixel per inches) of PNG file in Android

All your problems with Audio, Video and Images.

Change PPI (pixel per inches) of PNG file in Android

Postby tr4788 » Tue Nov 01, 2011 5:29 am

I have app which is used to edit PNG file (like write text on them).
My process is create bitmap from that PNG, use Canvas to draw Text, then use bitmap.compress to save result into SD Card.
Everything work fine. But when i check my result, i see that PPI was changed. How to keep that PPI like the Original one.
Here is the example: my Original image has 1300x700 res and 250 ppi (i checked with PS) but after use my app to edit that image, my result image has 1300x700 res and 72 ppi. I want my result image still has 1300x700 res and 250 ppi
Please help me, thanks for your help.

Here is the code:

Code: Select all
Bitmap bitmap = null;

try
{
      BufferedInputStream buf = new BufferedInputStream( PicksActivity.this.getAssets().open( file_name ) );

      bitmap = BitmapFactory.decodeStream( buf );
}
catch ( Exception e )
{
      // TODO: handle exception
}


Then create bitmap overlay:

Code: Select all
Bitmap bmOverlay = Bitmap.createBitmap( bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888 );


then compress it:

Code: Select all
bmOverlay.compress( CompressFormat.PNG, 100, fos );


This problem is not because of drawText, since when im not draw text, just open and save, PPI of result image is still change.
tr4788
Freshman
Freshman
 
Posts: 3
Joined: Tue Oct 18, 2011 2:44 am

Top

Re: Change PPI (pixel per inches) of PNG file in Android

Postby tr4788 » Wed Nov 02, 2011 10:29 am

help me please !!!
tr4788
Freshman
Freshman
 
Posts: 3
Joined: Tue Oct 18, 2011 2:44 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 15 guests