mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 20:50:42 +00:00
make Draw_SubPic do transparent pics
This commit is contained in:
parent
de22355371
commit
51b189f56a
1 changed files with 34 additions and 6 deletions
|
@ -372,8 +372,8 @@ void
|
||||||
Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
byte *dest, *source;
|
byte *dest, *source, tbyte;
|
||||||
int v;
|
int u, v;
|
||||||
|
|
||||||
if ((x < 0) ||
|
if ((x < 0) ||
|
||||||
(x + width > vid.width) || (y < 0) || (y + height > vid.height)) {
|
(x + width > vid.width) || (y < 0) || (y + height > vid.height)) {
|
||||||
|
@ -384,11 +384,39 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
||||||
|
|
||||||
dest = vid.buffer + y * vid.rowbytes + x;
|
dest = vid.buffer + y * vid.rowbytes + x;
|
||||||
|
|
||||||
|
if (width & 7) { // general
|
||||||
for (v = 0; v < height; v++) {
|
for (v = 0; v < height; v++) {
|
||||||
memcpy (dest, source, width);
|
for (u = 0; u < width; u++)
|
||||||
|
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u] = tbyte;
|
||||||
|
|
||||||
dest += vid.rowbytes;
|
dest += vid.rowbytes;
|
||||||
source += pic->width;
|
source += pic->width;
|
||||||
}
|
}
|
||||||
|
} else { // unwound
|
||||||
|
for (v = 0; v < height; v++) {
|
||||||
|
for (u = 0; u < width; u += 8) {
|
||||||
|
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u] = tbyte;
|
||||||
|
if ((tbyte = source[u + 1]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u + 1] = tbyte;
|
||||||
|
if ((tbyte = source[u + 2]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u + 2] = tbyte;
|
||||||
|
if ((tbyte = source[u + 3]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u + 3] = tbyte;
|
||||||
|
if ((tbyte = source[u + 4]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u + 4] = tbyte;
|
||||||
|
if ((tbyte = source[u + 5]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u + 5] = tbyte;
|
||||||
|
if ((tbyte = source[u + 6]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u + 6] = tbyte;
|
||||||
|
if ((tbyte = source[u + 7]) != TRANSPARENT_COLOR)
|
||||||
|
dest[u + 7] = tbyte;
|
||||||
|
}
|
||||||
|
dest += vid.rowbytes;
|
||||||
|
source += pic->width;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue