0
我将ios应用程序移植到android,并在从字节数组创建它时遇到位图颜色问题。此代码工作完全在iOS(C# - Xamarin):Android:创建的位图有错误的颜色
const int bitsPerComponent = 8;
const int bytePerPixel = 4;
var bytesPerRow = bytePerPixel * BarcodeImageWidth;
var colorSpace = CGColorSpace.CreateDeviceRGB();
var context = new CGBitmapContext(byteArray,
BarcodeImageWidth, BarcodeImageHeight,
bitsPerComponent, bytesPerRow,
colorSpace, CGImageAlphaInfo.NoneSkipFirst);
BarcodeImageView.Image = new UIImage(context.ToImage());
而在Android这个代码使用错误的颜色位图:
var bitmap = Bitmap.CreateBitmap(barcode.Width, barcode.Height, Bitmap.Config.Argb8888);
bitmap.CopyPixelsFromBuffer(ByteBuffer.Wrap(imageBytes));
barcode.SetImageBitmap(bitmap);
对我来说,它看起来像你imageBytes不包含数据在argb格式... – Selvin
@Selvin所以我能做什么呢? –