Android中位图通道顺序不同
我对Android中的Air本机扩展有问题 ANE从Actionscript端接收位图,将其压缩为jpeg格式并发送回Actionscript,Actionscript将其写入存储器 除了最后一件事,一切都很好 Actionscript的频道顺序似乎与Android不同,所以我的压缩图像用红色代替了蓝色。。代码如下: Actionscript(我正在使用一个名为deng.fzip.FZipLibrary的库从zip包中获取位图) AndroidAndroid中位图通道顺序不同,android,air,bitmap,air-native-extension,Android,Air,Bitmap,Air Native Extension,我对Android中的Air本机扩展有问题 ANE从Actionscript端接收位图,将其压缩为jpeg格式并发送回Actionscript,Actionscript将其写入存储器 除了最后一件事,一切都很好 Actionscript的频道顺序似乎与Android不同,所以我的压缩图像用红色代替了蓝色。。代码如下: Actionscript(我正在使用一个名为deng.fzip.FZipLibrary的库从zip包中获取位图) Android ... try { inputValue
...
try {
inputValue = (FREBitmapData)arg1[0];
inputValue.acquire();
int srcWidth = inputValue.getWidth();
int srcHeight = inputValue.getHeight();
Bitmap bm = Bitmap.createBitmap(srcWidth, srcHeight, Config.ARGB_8888);
bm.copyPixelsFromBuffer(inputValue.getBits());
ByteArrayOutputStream os = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 80, os);
compressed = os.toByteArray();
inputValue.release();
} catch (Exception e) {
e.printStackTrace();
}
try {
returnValue = FREByteArray.newByteArray();
returnValue.setProperty("length", FREObject.newObject(compressed.length));
returnValue.acquire();
ByteBuffer returnBytes = returnValue.getBytes();
returnBytes.put(compressed, 0, compressed.length);
returnValue.release();
}
...
有人知道如何在发送回图像之前将android端的红色转换为蓝色吗?还是需要在actionscript端完成
非常感谢和问候
Gianpiero您可以像这样切换颜色: (此代码并非源于我,不幸的是,我忘记了在哪里找到它,所以信用卡转到了其他地方) }
希望这有助于。。。Timm您可以像这样切换颜色: (此代码并非源于我,不幸的是,我忘记了在哪里找到它,所以信用卡转到了其他地方) }
希望这有助于。。。Timm我还尝试了其他Bitmap.Config值,但它们不好。。我想知道是否有可能创建一个与Actionscript通道顺序匹配的配置。我还尝试了其他Bitmap.config值,但效果不好。。我想知道是否有可能创建一个与Actionscript频道顺序匹配的配置。它成功了!!!你是生命的救世主!!非常感谢你,蒂姆,我怎样才能给你这个声誉信用???很高兴我能帮上忙。您可以将答案标记为“有用”,作为开始;)我不能那样做。。上面说我至少需要15个名声。。对不起,我是这里的新用户,我会在我能做的时候做!谢谢你再次工作!!!你是生命的救世主!!非常感谢你,蒂姆,我怎样才能给你这个声誉信用???很高兴我能帮上忙。您可以将答案标记为“有用”,作为开始;)我不能那样做。。上面说我至少需要15个名声。。对不起,我是这里的新用户,我会在我能做的时候做!再次感谢
...
try {
inputValue = (FREBitmapData)arg1[0];
inputValue.acquire();
int srcWidth = inputValue.getWidth();
int srcHeight = inputValue.getHeight();
Bitmap bm = Bitmap.createBitmap(srcWidth, srcHeight, Config.ARGB_8888);
bm.copyPixelsFromBuffer(inputValue.getBits());
ByteArrayOutputStream os = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 80, os);
compressed = os.toByteArray();
inputValue.release();
} catch (Exception e) {
e.printStackTrace();
}
try {
returnValue = FREByteArray.newByteArray();
returnValue.setProperty("length", FREObject.newObject(compressed.length));
returnValue.acquire();
ByteBuffer returnBytes = returnValue.getBytes();
returnBytes.put(compressed, 0, compressed.length);
returnValue.release();
}
...
private Bitmap m_encodingBitmap = null;
private Canvas m_canvas = null;
private Paint m_paint = null;
private final float[] m_bgrToRgbColorTransform =
{
0, 0, 1f, 0, 0,
0, 1f, 0, 0, 0,
1f, 0, 0, 0, 0,
0, 0, 0, 1f, 0
};
private final ColorMatrix m_colorMatrix = new ColorMatrix(m_bgrToRgbColorTransform);
private final ColorMatrixColorFilter m_colorFilter = new ColorMatrixColorFilter(m_colorMatrix);
...
try{
FREBitmapData as3Bitmap = (FREBitmapData)args[0];
as3Bitmap.acquire();
m_encodingBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
m_canvas = new Canvas(m_encodingBitmap);
m_paint = new Paint();
m_paint.setColorFilter(m_colorFilter);
m_encodingBitmap.copyPixelsFromBuffer(as3BitmapBytes);
as3Bitmap.release();
//
// Convert the bitmap from BGRA to RGBA.
//
m_canvas.drawBitmap(m_encodingBitmap, 0, 0, m_paint);
...