2012-07-27 16 views
-2

UIImageView不顯示/顯示原始圖像可用於服務器上。 更多的裁判check itUIImageView未將圖像顯示爲其原始圖像,可在服務器上使用

float scaleFactor = 0.0f;` 
float scaleWidth = dstRectangle.Width; //width =748 
float scaleHeight = dstRectangle.Height; // height = 759 
if(!SizeF.Equals(srcRectangle ,dstRectangle)) 
{ 
float widthFactor =(float) dstRectangle.Width/srcRectangle.Width; //srcRectHeight = 512 
float heightFactor =(float) dstRectangle.Height/srcRectangle.Height; //srcRectangle.Height = 314 
if(widthFactor >heightFactor) 
scaleFactor = widthFactor ; 
else 
scaleFactor = heightFactor; 
scaleWidth = srcRectangle.Width * scaleFactor; 
scaleHeight = srcRectangle.Height * scaleFactor; 
if(widthFactor >heightFactor) 
      { 
thumbnailPoint.Y = (dstRectangle.Height - scaleHeight) * .5f; 
} 
else 


if(widthFactor < heightFactor) 
{ 
thumbnailPoint.X = (dstRectangle.Width - scaleWidth) *.5f; 
} 
} 
UIGraphics.BeginImageContext(new SizeF(dstRectangle.Width , dstRectangle.Height)); 
RectangleF thumbnailRect = RectangleF.Empty; 
thumbnailRect.Offset(thumbnailPoint); 
thumbnailRect.Size.Width = scaleWidth; 

thumbnailRect.Size.Height = scaleHeight; 




CGImage _bitmap = UIGraphics.GetImageFromCurrentImageContext().CGImage; 
ImgVIew.Image = UIImage.FromImage(_bitmap); 
UIGraphics.EndImageContext(); 

它給了我的UIImage但在UIImageView的 不顯示在CGImage我ALphaInfo = PremultipledLast

BitsPerComponant = 8 

BitsPerPixel =32 

BytesPerRow = 3008 

Height= 759 

Width = 748 

這個值,我到CGImage但這CGImage我CONVER它到UIImage,但它仍然不能顯示

+3

我認爲你需要發佈一些代碼。否則,沒有人能夠幫助你。 – jonathanpeppers 2012-07-27 12:16:47

+0

檢查它我添加一些代碼 – IMMORTAL 2012-07-28 14:11:22

回答

0

你可以這樣做:

 using (var url = NSUrl.FromString ("http://yoururl.com/yourpic.jpg")) 
     { 
      using (var data = NSData.FromUrl (url)) 
      { 
       imageView.Image = UIImage.LoadFromData (data); 
      } 
     } 

這聽起來像你只需要下載一個圖像並將其設置爲UIImageView,對吧?

看來你正在爲很簡單的東西寫很多代碼。

注意:使用try-catch來查找聯網錯誤。

+0

我的圖像是RLE壓縮圖像,同時從LOADFROMDATA(數據)方法中返回值,它返回NULL。所以可以請告訴我如何可以將此RLE文件轉換爲UIImage支持的文件擴展名爲此我使用CGImage的核心高度,它的工作寬度,但圖像不正確渲染 – IMMORTAL 2012-07-31 07:08:45

+0

您需要使用一些代碼先解壓縮RLE,然後創建來自解壓後的'byte []'圖像。快速瀏覽谷歌,我發現這個類:http://code.google.com/p/dsdecmp/source/browse/trunk/CSharp/DSDecmp/Formats/Nitro/RLE.cs?r=23可能有一個更好的C#庫,用於RLE壓縮/解壓縮,但想法是解壓縮,然後創建'UIImage'。 – jonathanpeppers 2012-07-31 12:10:52