No image component suitable for completing this operation was found.

Here is my piece of code, but I have an error

No image component suitable for completing this operation was found.

in the line < EndInit () .

I read the WIC registry modification (NB: my OS is Windows 7 and my IDE is VS 2010), but it does not work at all: (

I was wondering if you tell me what to do to solve this problem.

BitmapImage myBitmapImage = new BitmapImage(); byte[] DM = new byte[307200]; for (int i = 0; i < 640; i++) for (int j = 0; j < 480; j++) if (i < 500) DM[i + j] = i; using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(DM)) { myBitmapImage.BeginInit(); myBitmapImage.StreamSource = memoryStream; myBitmapImage.DecodePixelWidth = 640; myBitmapImage.EndInit(); } img.Source = myBitmapImage; 
+4
source share
1 answer

Well, you can't just pass in an array of pixel data; the class cannot know what the length and height are, what channels and what color depth the image should have. You need to provide a valid title for the supported formats, for example. bmp, jpg or png. There are some others, the list exists somewhere on MSDN.

Since you want to create a bitmap from scratch, you can use WritableBitmap .

(By the way, DecodePixelWidth not what you apparently think it does, it just scales the image down after decoding it to save memory)

+4
source

All Articles