2012-08-09 70 views
0

我有一個關於UIImageView和UIImage的問題我對1件事感到困惑,例如我的「UIImageView Height = 759和Width = 748」我正在從服務器下載圖像高度和寬度是如此如此較大的如「圖像高度= 2048和Width = 2500」我傳遞給CGimage高度n寬度的哪個參數

讓我有點迷惑,而渲染上的UIImageView圖像我傳遞參數到CGImage

我將參數傳遞給CGImage,如下所示

CGImage _bitmap = new CGImage (2048 , 2500 , 8 , 32 , 2048 * 4 , _colorSpace , CGBitmapFlag.ByteOrderDefault , null, true , CGColorRenderingIntent.Default); 

我通過在CGImage()的類型參數的意思我通過圖片參數或UIImageView的參數CGImage讓我的形象將正確渲染成UIImaeView

回答

0

我不認爲你應該費心使用CGImage在所有(除非你特別有內存問題)。

只是這樣做:

UIImage yourImage; 
//Download from your server here (I can fill it in if needed) 
UIImageView imageView = new UIImageView(new Frame(0, 0, 748, 759)); //This can also be setup in a XIB file 
imageView.ContentMode = UIViewContentMode.ScaleAspectFit; 
imageView.Image = yourImage; 

玩的內容模式設置,以獲得您需要什麼。

Here是內容模式的鏈接。

+0

感謝您的rlpy我知道內容模式屬性,但它的工作圖像不適合UIImageVIew – IMMORTAL 2012-08-09 13:44:33

+0

當你嘗試這種方法會發生什麼?屏幕是什麼樣子的,你可以發佈一個屏幕截圖嗎?這種方法應該適合你。 – jonathanpeppers 2012-08-09 14:14:31

+0

爲什麼不,但檢查此鏈接,以便您可以找到屏幕截圖:-http://monotouch.2284126.n4.nabble.com/How-to-display-12-bit-images-in-UIImageView-td4656427 .html – IMMORTAL 2012-08-10 11:13:06

相關問題