> Am 04.02.2020 um 22:15 schrieb Sergii Stoian <stoyan...@gmail.com>:
> 
>> On Feb 4, 2020, at 20:43, Fred Kiefer <fredkie...@gmx.de> wrote:
>> In general it is safer as the new code expects that the image is fully 
>> packed. (You moved the comment with the conversion from unpacked to packed 
>> over to the swap function) If bytesPerRow is not equal to w * 4 (there may 
>> be a few extra bytes to align stuff a bit), then the new code would not 
>> transfer the correct data.  We would end up with random garbage in between. 
>> But in this special case the image comes from GSStandardImage and at least 
>> for the case where there are alpha values that function should already 
>> return a packed image. Thinking about it the old code should only have 
>> copied w * 4 bytes for each row. The old code could have written a few bytes 
>> past the pixels array.
> 
> Clear explanation, thank you. It is a usual case when image contains more 
> bytes than image size (width * height)?
> I feel we need to return back old code with your explanation in comment.
> What do you think?

I just committed a merge of the two approaches (plus a few compiler warning 
fixes). I hope this should fix Riccardo's issues. It might also be slightly 
faster as I removed the copy before the colour swap. At least the swapColor 
function now does what the comment above it claims :-)

Fred

Reply via email to