0
我正在使用robovm並希望顯示一些在UIImage中遠程接收的圖像。有兩種方法可以獲取圖像(並且由於它們來自其他來源,因此無法更改)。一些以JPEG形式發送,一些以int數組形式發送。現在,轉換成UIImage的整型圖像拒絕吸引到喜歡這裏圖像內容,RoboVM中的圖像
NSData imgData = new NSData(array);
CGDataProvider provider = CGDataProvider.create(imgData);
CGImage img = CGImage.create((long) size.getWidth(), (long) size.getHeight(),
8, 32, (long) (size.getWidth()) * 4, CGColorSpace.createDeviceRGB(), new CGBitmapInfo(CGImageAlphaInfo.PremultipliedFirst.value()),
provider, null, false, CGColorRenderingIntent.Default);
UIGraphics.beginImageContext(size);
fullscreen.draw(CGPoint.Zero(), CGBlendMode.Normal, 1.0);
UIImage uimg = new UIImage(img);
uimg.draw(new CGRect(rect.x, rect.y, rect.width, rect.height), CGBlendMode.Normal, 1.0);
fullscreen = UIGraphics.getImageFromCurrentImageContext();
UIGraphics.endImageContext();
但是,當這樣做正確顯示出來:
NSData imgData = new NSData(array);
CGDataProvider provider = CGDataProvider.create(imgData);
CGImage img = CGImage.create((long) size.getWidth(), (long) size.getHeight(),
8, 32, (long) (size.getWidth()) * 4, CGColorSpace.createDeviceRGB(), new CGBitmapInfo(CGImageAlphaInfo.PremultipliedFirst.value()),
provider, null, false, CGColorRenderingIntent.Default);
fullscreen = new UIImage(img);
然而,在這種情況下,我不能表現出圖像與JPEG一起,因爲它需要首先繪製背景。我該怎麼辦?