简体   繁体   English

小尺寸,高分辨率图像

[英]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: 要记住一些概念:

  1. The original resolution of the picture (In your case 3000x4000 pixels) 图片的原始分辨率(在你的情况下为3000x4000像素)
  2. The resolution of the display . 显示器的分辨率。 For example, a Nexus 4 has a display of 768x1,280 pixels. 例如,Nexus 4的显示屏为768x1,280像素。 Displays have an important property: DPI or dots per inch. 显示器具有重要属性:DPI或每英寸点数。 This is the number of pixels that together measure 1 inch (25.4mm) on the physical screen. 这是在物理屏幕上一起测量1英寸(25.4毫米)的像素数。 Apple's 'retina' displays on the iPhone have a DPI of 326 - this is the benchmark of sharpness; 苹果iPhone上的“视网膜”显示器的DPI为326 - 这是锐度的基准; pixels on this screen are too small for the human eye to see individually/sharply at typical holding distance. 此屏幕上的像素太小,人眼无法在典型的保持距离下单独/清晰地看到。 Old monotone LCD displays have a DPI somewhere in the 30-60 range - you can easily see the square shape of individual pixels. 旧单调LCD显示器的DPI在30-60范围内 - 您可以轻松看到单个像素的方形。
  3. The portion of the picture to be shown on the display - the view port . 要在显示屏上显示的图片部分 - 视口 There are two different extremes: 有两种不同的极端:

    1. Zoom out : You want the complete picture shown on the display. 缩小 :您需要显示屏上显示的完整图片。 In your case, the picture has more pixels than the display (the display has a physical limitation that there are not enough pixels to show the original picture at the original resolution), so one pixel on the display will render a group of pixels from the picture, averaging the colour and brightness, or 在您的情况下,图片的像素比显示器多(显示器的物理限制是没有足够的像素以原始分辨率显示原始图片),因此显示器上的一个像素将呈现一组像素图片,平均颜色和亮度,或
    2. Natural resolution : Natural resolution is where one pixel from the original image is displayed on precisely one pixel on the screen. 自然分辨率 :自然分辨率是指原始图像中的一个像素恰好显示在屏幕上的一个像素上。 In you case you would only get to see about than a quarter of the image. 在你的情况下,你只能看到大约四分之一的图像。 This scaling has the greatest sharpness , but some details of the image may be too small to see, because the eye cannot actually see the individual display pixels. 这种缩放具有最大的清晰度 ,但是图像的一些细节可能太小而无法看到,因为眼睛实际上看不到单独的显示像素。
    3. Zoom in : You want to display an even smaller portion of the picture on the display, where the original pixels from the picture are actually larger than the display. 放大 :您希望在显示屏上显示图像的更小部分,其中图像中的原始像素实际上大于显示。 Here one pixel from the picture will be displayed on several or many pixels on the display. 这里,图片中的一个像素将显示在显示器上的几个或多个像素上。

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种方法可以减小图像的大小:

  • Reduce it's size and or quality (for instance by reducing the amount of pixels, or the size of each pixel) - Jpeg does something very similar to this. 减少它的大小和/或质量(例如通过减少像素数量或每个像素的大小) - Jpeg做了与此非常相似的事情。
  • Compress the file - which is what GIF and PNG does. 压缩文件 - 这是GIF和PNG的作用。
  • Use vector graphics. 使用矢量图形。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM