0
Rgb24가있는 WriteableBitmap을 pixelFormat으로 변환하려고합니다. Bgr 형식의 EmguCV Image에 동일한 이미지를 저장하려고합니다. 다음 코드를 작성했지만 적절한 결과를 제공하지 않습니다.RGB24 픽셀 형식의 WriteableBitmap을 EmguCV 이미지 <Bgr, Byte> 형식으로 변환하는 방법은 무엇입니까?
public unsafe void Convert(WriteableBitmap bitmap)
{
byte[] retVal = new byte[bitmap.PixelWidth * bitmap.PixelHeight * 4];
bitmap.CopyPixels(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight), retVal, bitmap.PixelWidth * 4, 0);
Bitmap b = new Bitmap(bitmap.PixelWidth, bitmap.PixelHeight);
int k = 0;
byte red, green, blue, alpha;
for (int i = 0; i < bitmap.PixelWidth; i++)
{
for (int j = 0; j < bitmap.PixelHeight && k<retVal.Length; j++)
{
alpha = retVal[k++];
blue = retVal[k++];
green = retVal[k++];
red = retVal[k++];
System.Drawing.Color c = new System.Drawing.Color();
c = System.Drawing.Color.FromArgb(alpha, red, green, blue);
b.SetPixel(i, j, c);
}
}
currentFrame = new Image<Bgr, byte>(b);
currentFrame.Save("Converted.jpg");
}
미리 감사드립니다.