int *Pixel = (int*)Row;
I mean, why do we have to typecast the row pointer every time.
if we only typecast it before the loop, does it only point to (int*) once, and then point to (char*) for the rest of the loop??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | void drawRectangle(BitmapInfo *bmpInfo, int x, int y, int width, int height, int Color) { if(x < 0) { x = 0; } if(y < 0) { y = 0; } if(width > bmpInfo->width) { width = bmpInfo->width; } if(height > bmpInfo->height) { height = bmpInfo->height; } int Pitch = bmpInfo->width * 4; char *Row = (char*)bmpInfo->memory + (x * 4) + (y * Pitch); here? <-------------------------------------------------- for(int yi = y; yi < height; yi++) { int *Pixel = (int*)Row; <-------- why doesn't it work to put this outside the loop? for(int xi = x; xi < width; xi++) { *Pixel++ = Color; } Row += Pitch; } } |