Am 02.01.2016 um 07:24 schrieb Aaryaman Vasishta <jem456.vasishta(a)gmail.com>:
+ size = w * h * (bpp / 8); + /* Saving pixels by directly accessing bitmap buffer is faster than using SetPixel */ + for (i = 0, j = 0; i < size;) + { + if (palettized) + { + buffer[i++] = j; + buffer[i++] = j; + buffer[i++] = j++; + j %= 256; + } + else + { + buffer[i] = i % 256; + i++; + buffer[i] = j % 256; + i++; + j = (j % w) + 1; + } + } This is different from earlier patch versions afair. Whats the reason for the change?
I guess this gets the job done, but it feels a bit odd to initialize 2/3rds of a rgb pixel or 3 palletized pixels per iteration. It can also cause trouble with writing past the end if size isn't a multiple of 2 or 3 respectively. (with 24 bit rgb even a multiple of 2 isn't guaranteed) Also I think you can get rid of the DIB section and just use a HeapAlloced blob.