[英]Small Size , High Resolution Images
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: 我创建应用程序称为它(应用程序A),需要在res drawable文件夹中存储大量的高分辨率图像,(我知道我可以远程下载,但我需要将它保存在drawable res文件夹中),它:
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 3000 x 4000数码相机拍摄的JPEG图像 ,因为这将导致不可接受的增加应用程序大小并导致在设备上运行时出现内存异常,因此我们可以创建另一个名为
( 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 , (应用程序B),仅用于调整图像大小,这将选择将存储在SD上的图像 (仅用于调整大小),然后将其调整为较小尺寸的图像,但不会丢失图像质量并保持高图像分辨率 ,然后保存再次使用PNG或JPEG格式的SD ,然后我可以从SD卡获取图像然后将其保存到(app A)资源文件并使用它,具有合理的大小和高分辨率,
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. 注意:我尝试使用计算机软件:photoshop或格式工厂,但都会影响分辨率。
your help will be highly appreciated and thanks. 您的帮助将受到高度赞赏和感谢。
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. 你将你的图像分成许多较小的“瓷砖”,比如500x500px,然后将它们放在网格上 - 选择你喜欢的布局。 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 以下是更多详细信息的参考: 如何在android中平铺和滚动大图像(10000x10000)
To split the image, follow the instructions here: Android - Split Drawable 要分割图像,请按照此处的说明操作: 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 我的目标是拥有3000 * 4000分辨率的大图片,我想将其转换为更小的尺寸,但保持相同的分辨率
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. 现在,Android图像库将有所帮助。 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. 我希望借助这种新语言,您可以看到基本约束,因此可以决定如何继续。
Use BitmapFactory.Options.inSampleSize to read a subsampled bitmap. 使用BitmapFactory.Options.inSampleSize读取子采样位图。
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. 并使用Bitmap.compress()将位图保存到SD卡。
EDIT: If you still want to keep the resolution, you can try to set BitmapFactory.Options.inPreferredConfig = Bitmap.Config.RGB_565;
编辑:如果你仍然想保持分辨率,你可以尝试设置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. 为了解码位图,这可以减少一半的内存成本,因为大多数默认配置是RGB_8888。
There are basically 3 ways in which you can reduce the size of an image: 基本上有3种方法可以减小图像的大小:
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). 由于您正在讨论进一步压缩数码相机jpeg图像,因此您无法在不降低质量的情况下进一步降低图像本身(JPEG已经降低了质量并压缩文件,这就是为什么它是最常用的类型网络)。 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. 从理论上讲,如果您可以将所有图像一起添加到单个图像中,并将其压缩为单个图像,则可能会获得一些基础,但在讨论此类尺寸时,您不可能再处理此类图像。一个巨大的文件。
As you said you already try photoshop and gain unacceptable result concerning the resolution , 正如你所说,你已经尝试过photoshop并获得有关分辨率的不可接受的结果,
there is simple trick found in Photoshop CS and CS2 only : 仅在Photoshop CS和CS2中找到了简单的技巧 :
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 改编自以下链接: http : //www.photoshopsupport.com/tutorials/jennifer/bicubic.html
Hope thats help . 希望有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.