Am 02.01.2016 um 07:24 schrieb Aaryaman Vasishta jem456.vasishta@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.
On Sun, Jan 3, 2016 at 2:54 AM, Stefan Dösinger stefandoesinger@gmail.com wrote:
This is different from earlier patch versions afair. Whats the reason for the change?
Using i % 251 didn't give > 256 colors on larger images. So I just came up with a random way of getting it done without needing to use a random number generator. I'll change it to look less awkward though.
Cheers, Aaryaman