Skip to content

Commit

Permalink
Readability improvement in clipbitmap()
Browse files Browse the repository at this point in the history
  • Loading branch information
DCurrent committed Mar 19, 2018
1 parent 6b9613b commit 3957c97
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions engine/source/gamelib/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ void flipbitmap(s_bitmap *bitmap)


// Clipbitmap: cuts off transparent edges to optimize a bitmap.
void clipbitmap(s_bitmap *bitmap, int *clipl, int *clipr, int *clipt, int *clipb)
void clipbitmap(s_bitmap *bitmap, int *clip_left, int *clip_right, int *clip_top, int *clip_bottom)
{

int x, y, i;
int clip, clear;
int xsize = bitmap->width;
int ysize = bitmap->height;
int tclipmove = 0;
int lclipmove = 0;
int bclipmove = 0;
int rclipmove = 0;
int top_clipmove = 0;
int left_clipmove = 0;
int bottom_clipmove = 0;
int right_clipmove = 0;



Expand Down Expand Up @@ -241,21 +241,21 @@ void clipbitmap(s_bitmap *bitmap, int *clipl, int *clipr, int *clipt, int *clipb
if(ysize < 1)
{
// If nothing is left of the bitmap, return...
if(clipl)
if(clip_left)
{
*clipl = 0;
*clip_left = 0;
}
if(clipr)
if(clip_right)
{
*clipr = 0;
*clip_right = 0;
}
if(clipt)
if(clip_top)
{
*clipt = 0;
*clip_top = 0;
}
if(clipb)
if(clip_bottom)
{
*clipb = 0;
*clip_bottom = 0;
}
bitmap->width = 0;
bitmap->height = 0;
Expand All @@ -266,7 +266,7 @@ void clipbitmap(s_bitmap *bitmap, int *clipl, int *clipr, int *clipt, int *clipb
{
bitmap->data[i] = bitmap->data[i + (clip * xsize)];
}
tclipmove = clip;
top_clipmove = clip;
}


Expand Down Expand Up @@ -296,7 +296,7 @@ void clipbitmap(s_bitmap *bitmap, int *clipl, int *clipr, int *clipt, int *clipb
// Cut off empty bottom
ysize -= clip;
bitmap->height = ysize;
bclipmove = clip;
bottom_clipmove = clip;


// Determine size of empty left side
Expand Down Expand Up @@ -330,7 +330,7 @@ void clipbitmap(s_bitmap *bitmap, int *clipl, int *clipr, int *clipt, int *clipb
bitmap->data[y * xsize + x] = bitmap->data[y * xsize + x + (clip * (y + 1))];
}
}
lclipmove = clip;
left_clipmove = clip;
}

// Determine size of empty right side
Expand Down Expand Up @@ -364,24 +364,24 @@ void clipbitmap(s_bitmap *bitmap, int *clipl, int *clipr, int *clipt, int *clipb
bitmap->data[y * xsize + x] = bitmap->data[y * xsize + x + (clip * y)];
}
}
rclipmove = clip;
right_clipmove = clip;
}

if(clipl)
if(clip_left)
{
*clipl = lclipmove;
*clip_left = left_clipmove;
}
if(clipr)
if(clip_right)
{
*clipr = rclipmove;
*clip_right = right_clipmove;
}
if(clipt)
if(clip_top)
{
*clipt = tclipmove;
*clip_top = top_clipmove;
}
if(clipb)
if(clip_bottom)
{
*clipb = bclipmove;
*clip_bottom = bottom_clipmove;
}
}

Expand Down

0 comments on commit 3957c97

Please sign in to comment.