Open GoogleCodeExporter opened 8 years ago
On further thought, image2.bmp and image3.bmp won't be very good duplicates of
image.bmp unless the latter is 1bpp (50% chance) or 32bpp, or you copy the
palettes, which I didn't do in my test.
Original comment by dales...@gmail.com
on 2 Feb 2012 at 2:15
Original comment by andrew.k...@gmail.com
on 2 Feb 2012 at 9:49
The suggested fix actually just touches the very top of big iceberg. To me it
does not fit the problem completely, but just fixes one single function.
All other classes (image processing filter) simply don't even suspect that
stride could be negative. Even the UnmanagedImage will fail in other method,
like Clone():
>> IntPtr newImageData = System.Runtime.InteropServices.Marshal.AllocHGlobal(
stride * height );
The issue needs to be fixed either for all methods/classes, which s quite a
lot. Or the constructor of the UnmanagedImage needs to be fixed to throw
exception for negative stride. And then some conversion routine needs to be
added in user’s code, which takes care of converting 3rd party images into
proper ones. I would go for the last one.
Original comment by andrew.k...@gmail.com
on 2 Feb 2012 at 8:27
I don't know why that vendor did things backward, but .NET handles such images
correctly.
From a brief look through the edge detectors, I think the filters proper might
not need to be changed at all. As far as I can tell, any time where stride is
used as a pointer offset will work without modification, and the filters seem
to only ever use the stride that way.
Looking around elsewhere, Apply(Bitmap) and Apply(BitmapData) will need to be
touched in the base filters, so they don't barf on negative-stride
bitmap(data)s. BaseUsingCopyPartialFilter would also need to be touched in
ApplyInPlace(UnmanagedImage,Rectangle). I'm sure there are other places, but if
it turns out to be merely "touch every base filter", it might still be worth
the effort. I'll investigate more over the weekend.
Original comment by dales...@gmail.com
on 2 Feb 2012 at 10:26
Original issue reported on code.google.com by
dales...@gmail.com
on 1 Feb 2012 at 10:20Attachments: