2015-05-24 65 views
0

從Cloudinary(或其他Picture-CDN)加載圖像時,在視網膜顯示器上的UIImageView中顯示的正確圖像尺寸是什麼?使用Cloudinary爲iPhone(Retina)製作的完美圖像尺寸

一方面,我有一個Table,每個TableCell都有自己的UIImageView,寬度和高度均爲70px。另一方面,我用背景圖覆蓋了整個屏幕的全部尺寸。 每個圖像都從Cloudinary加載,我可以請求特定圖像大小的圖像下載。由於視網膜顯示器需要原始圖像的兩倍大小(據我所知),我想,我必須從Cloudinary請求圖像的雙倍大小,不是嗎?因此,對於尺寸爲70x70像素的UIImageView,我會請求140x140像素的圖像縮略圖,而對於屏幕背景圖像,我會要求screenWidth * 2和screenHeight * 2從圖像加載圖像Cloudinary。

我是錯的還是我的假設是正確的?

回答

0

看到這個:https://github.com/cloudinary/cloudinary_ios
特定的圖像尺寸網址:

// 150 * 100 
http://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill/sample.jpg 
// 250 * 300 
http://res.cloudinary.com/demo/image/upload/w_250,h_300,c_fill/sample.jpg 

或使用CLTransformation

CLTransformation *transformation = [CLTransformation transformation]; 
[transformation setWidthWithInt: 100]; 
[transformation setHeightWithInt: 150]; 
[transformation setCrop: @"fill"]; 

NSString *url = [cloudinary url:@"sample.jpg" options:@{@"transformation": transformation}]; 

// http://res.cloudinary.com/n07t21i7/image/upload/c_fill,h_150,w_100/sample.jpg 
+1

這不是一個回答我的問題。我知道如何請求不同的圖像大小。我的問題是:我應該選擇雙倍圖像大小而不是UIImageView的大小,圖片將放置在哪裏? – delete

+1

你說得對。圖像將通過UIKit進行適當縮放,實際上它是受Retina顯示影響的UIImageView。 – Bannings

+1

此外,您可以使用Cloudinary的自動DPR檢測和傳遞功能,而不是明確要求雙倍大小的圖像:http://cloudinary.com/blog/how_to_automatically_adapt_website_images_to_retina_and_hidpi_devices –