Browse Source

clip minimum X/Y

master
CrunkLord420 5 months ago
parent
commit
38f425f745
1 changed files with 15 additions and 3 deletions
  1. +15
    -3
      PxBlot.HC

+ 15
- 3
PxBlot.HC View File

@ -15,22 +15,34 @@ public U0 PxBlot(CDC *dc, PxData *data, I64 x, I64 y) {
}
// Clip X
I64 minX = 0;
if (x < 0) {
minX = -x;
x = 0;
}
I64 maxX = data->width;
if (maxX+x >= dc->width_internal) {
maxX -= maxX+x - dc->width_internal;
}
// Clip Y
I64 minY = 0;
if (y < 0) {
minY = -y;
y = 0;
}
I64 maxY = data->height;
if (maxY+y >= dc->height) {
maxY -= maxY+y - dc->height;
}
// Draw
I64 d = dc->body + y*dc->width_internal + x;
y = 0;
I64 dy, dx;
for (dy=0; dy<maxY; dy++) {
U8 *dst = d + dy*dc->width_internal;
for (dx=0; dx<maxX; dx++, dst++) {
for (dy=minY; dy<maxY; y++, dy++) {
U8 *dst = d + y*dc->width_internal;
for (dx=minX; dx<maxX; dx++, dst++) {
U8 color = data->body[dy*data->width+dx];
if (color != TRANSPARENT) {
*dst = color;


Loading…
Cancel
Save