mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-26 16:38:06 +03:00
This replaces BYTE, WORD and DWORD types with uint8_t, uint16_t and uint32_t respectively.
55 lines
837 B
C
55 lines
837 B
C
// fill rectangle
|
|
|
|
#include <string.h>
|
|
#include "portab.h"
|
|
#include "surface.h"
|
|
#include "ngraph.h"
|
|
#include "ags.h"
|
|
|
|
int gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b) {
|
|
uint8_t *dp, *dp_;
|
|
int x, y;
|
|
|
|
if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) {
|
|
return NG;
|
|
}
|
|
|
|
dp = dp_ = GETOFFSET_PIXEL(dst, dx, dy);
|
|
|
|
switch(dst->depth) {
|
|
case 8:
|
|
memset(dp, r, dw);
|
|
break;
|
|
|
|
case 16:
|
|
{
|
|
uint16_t pic16 = PIX16(r, g, b);
|
|
|
|
for (x = 0; x < dw; x++) {
|
|
*((uint16_t *)dp + x) = pic16;
|
|
}
|
|
|
|
break;
|
|
}
|
|
case 24:
|
|
case 32:
|
|
{
|
|
uint32_t pic24 = PIX24(r, g, b);
|
|
|
|
for (x = 0; x < dw; x++) {
|
|
*((uint32_t *)dp + x) = pic24;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
dp += dst->bytes_per_line;
|
|
for (y = 1; y < dh; y++) {
|
|
memcpy(dp, dp_, dw * dst->bytes_per_pixel);
|
|
dp += dst->bytes_per_line;
|
|
}
|
|
|
|
return OK;
|
|
}
|