I have a TransformedBitmap 2208 x 3000 object with the format {Indexed8}, which I make .CopyPixels () on. I use
(int)((formattedBitmap.PixelWidth * formattedBitmap.Format.BitsPerPixel + 7) / 8)
(it is assumed that "formattedBitmap" is the name of the image from which I am trying to copy pixels) for the value "stride" in my method call and byte array of length 2208. I have something like this working elsewhere in the code (where the image format is {Gray8}. However, when I try to do the same in the above image, I constantly get an "Argument out of range" exception: "The value of the parameter cannot be less than" 6624000 ". \ r \ nParameter: buffer."
My questions are about this: why in the world is the exact same code working in one place and not in another? What in the world, in the conditions of the layman, really is a "step"? And how can I get the desired effect (on copying bits) without getting this error? What am I doing wrong?
Any help on this would be greatly appreciated. Many thanks!
c # image-processing byte wpf pixels
Jtoland
source share