Reputation: 1526
I create app called it ( app A ) which need to store large No. of high resolution images in res drawable folder , ( i know that i can downloaded remotely , but i need to keep it in drawable res folder ) , its:
3000 x 4000 JPEG images taken by digital camera , as this will lead to unacceptable increase app size and lead to rise memory exception when run it on device ,so can we create another app called
( app B ) , just for resizing the images , which will pick this images that will be stored on SD
( just for purpose of resizing ), then resize it to smaller sized images but without loss image quality and keep high image resolution , then save it again to SD either with PNG or JPEG format , so then i can take images from SD card then save it to ( app A ) resource file and use it , with reasonable size and high resolution ,
hope if any one can supply tutorial or link explaining that or an full code answer applying this ,
Note : i tried using computer software as : photoshop or format factory but all affect the resolution.
your help will be highly appreciated and thanks.
Upvotes: 4
Views: 5265
Reputation: 19651
This is best solved using image tiling. You break your image into a number of smaller 'tiles', say 500x500px which are then laid out on a grid - pick your favorite layout. For rendering zoomed in, only those tiles that are on-screen will be drawn.
Here is a reference for more details: How to tile and scroll a large image (10000x10000) in android
To split the image, follow the instructions here: Android - Split Drawable
For really smooth behaviour, you can additionally create a scaled down image from the original and use the downscaled tiles when the grid is zoomed out. Switch back to the original resolution as the user zooms in.
EDIT
my goal im have large pic of 3000*4000resolution i want to transform it to smaller size but keep same resolution
There are a few concepts to keep in mind:
The portion of the picture to be shown on the display - the view port. There are two different extremes:
Now, the Android image libraries will help. When you render an image on the display, the libraries will scale the picture to "fit" the pixels on the display - your actual picture will be unaltered.
I hope with this new language that you can see the fundamental constraints and can therefore decide how to proceed.
Upvotes: 4
Reputation: 4314
As you said you already try photoshop and gain unacceptable result concerning the resolution ,
there is simple trick found in Photoshop CS and CS2 only :
When you want to reduce an image go to the Image> Image Size menu. Click on
Resample Image and choose Bicubic Sharper from the drop-down menu. This is the
best setting for making sure that an image doesn't blur. The example photo of the
flower started at 2,000 pixels across. I stepped it down to 250, and then again
to 125 with almost no loss of sharpness.
Another thing to keep in mind
when resizing is to try to do it only once on an image.
Many people will resize repeatedly as they search for the perfect fit for
a design element, and then end up with an image with a lot of blur. It's always
better to experiment on a duplicate of the image. Then, when you've settled on
the final dimensions, you can go back to the original and resize it just once.
I already try it my self and have a nice resulted image resolution with small size .
Adapted from this link : http://www.photoshopsupport.com/tutorials/jennifer/bicubic.html
Hope thats help .
Upvotes: 1
Reputation: 1727
There are basically 3 ways in which you can reduce the size of an image:
Since you are talking about further compressing a digital camera jpeg image, there's not much you can do to reduce the image itself further without losing more quality (JPEG already both reduces quality and compresses the file, which is why it is the most used type on the web). Any attempt to compress the file without further reducing quality won't give you much ground (though you can try several different compressing schemes, and theres a rare chance you'll hit just the right scheme to gain some substantial reduction).
In theory if you can add all the images together into a single image, and compress it as a single image, it's possible that you can gain some ground, but when talking about such sizes, it's unlikely you'll ever be able to process such a huge file.
Upvotes: 1
Reputation: 7450
Use BitmapFactory.Options.inSampleSize to read a subsampled bitmap.
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 2;
Bitmap bitmap = BitmapFactory.decodeFile(pathName, opts);
And use Bitmap.compress() to save the bitmap to sdcard.
EDIT:
If you still want to keep the resolution, you can try to set BitmapFactory.Options.inPreferredConfig = Bitmap.Config.RGB_565;
to decode bitmap, this could reduce by half the memory cost since most default config is RGB_8888.
Upvotes: 1