mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-27 06:01:24 +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)
|
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;
|
return NULL;
|
||||||
|
|
||||||
if (Patch_NeedsUpdate(patch))
|
if (Patch_NeedsUpdate(patch))
|
||||||
|
@ -244,6 +244,17 @@ void *Patch_GetPixel(patch_t *patch, INT32 x, INT32 y)
|
||||||
if (patch->columns == NULL)
|
if (patch->columns == NULL)
|
||||||
return 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];
|
column_t *column = &patch->columns[x];
|
||||||
|
|
||||||
for (unsigned i = 0; i < column->num_posts; i++)
|
for (unsigned i = 0; i < column->num_posts; i++)
|
||||||
|
|
Loading…
Reference in a new issue