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

819 views Asked by At

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 it is:

        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:

Bitmap bmOverlay = Bitmap.createBitmap( bitmap.getWidth(), bitmap
                    .getHeight(), Config.ARGB_8888 );

and them compress it:

bmOverlay.compress( CompressFormat.PNG, 100, fos );

this problem not because of drawText, cause when im not draw text, just open and save, PPI still change.

0

There are 0 answers