mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-26 21:51:04 +00:00
Add shortcut to Patch_GetPixel
This commit is contained in:
parent
dca643676c
commit
f464297169
1 changed files with 12 additions and 1 deletions
|
@ -235,7 +235,7 @@ column_t *Patch_GetColumn(patch_t *patch, unsigned column)
|
|||
|
||||
void *Patch_GetPixel(patch_t *patch, INT32 x, INT32 y)
|
||||
{
|
||||
if (x < 0 || x >= patch->width)
|
||||
if (x < 0 || x >= patch->width || y < 0 || y >= patch->height)
|
||||
return NULL;
|
||||
|
||||
if (Patch_NeedsUpdate(patch))
|
||||
|
@ -244,6 +244,17 @@ void *Patch_GetPixel(patch_t *patch, INT32 x, INT32 y)
|
|||
if (patch->columns == NULL)
|
||||
return NULL;
|
||||
|
||||
bitarray_t *pixels_opaque = Patch_GetOpaqueRegions(patch);
|
||||
if (pixels_opaque)
|
||||
{
|
||||
size_t position = (x * patch->height) + y;
|
||||
|
||||
if (!in_bit_array(pixels_opaque, position))
|
||||
return NULL;
|
||||
|
||||
return &patch->pixels[position];
|
||||
}
|
||||
|
||||
column_t *column = &patch->columns[x];
|
||||
|
||||
for (unsigned i = 0; i < column->num_posts; i++)
|
||||
|
|
Loading…
Reference in a new issue