Skip to content

Commit

Permalink
Using DrawBitmap instead of DrawBitmapComposited when graphics will n…
Browse files Browse the repository at this point in the history
…ever overlap.
  • Loading branch information
MainMemory committed May 24, 2016
1 parent e051c01 commit e3b1c04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
21 changes: 17 additions & 4 deletions SonLVLAPI/DataTypes.cs
Expand Up @@ -2360,11 +2360,12 @@ public Sprite(params Sprite[] sprites)

public Sprite(IEnumerable<Sprite> sprites)
{
List<Sprite> sprlst = new List<Sprite>(sprites);
int left = 0;
int right = 0;
int top = 0;
int bottom = 0;
foreach (Sprite spr in sprites)
foreach (Sprite spr in sprlst)
if (spr.Image != null)
{
left = Math.Min(spr.Left, left);
Expand All @@ -2374,9 +2375,21 @@ public Sprite(IEnumerable<Sprite> sprites)
}
Offset = new Point(left, top);
Image = new BitmapBits(right - left, bottom - top);
foreach (Sprite spr in sprites)
if (spr.Image != null)
Image.DrawBitmapComposited(spr.Image, new Point(spr.X - left, spr.Y - top));
for (int i = 0; i < sprlst.Count; i++)
if (sprlst[i].Image != null)
{
bool comp = false;
for (int j = 0; j < i; j++)
if (sprlst[j].Image != null && sprlst[i].Bounds.IntersectsWith(sprlst[j].Bounds))
{
comp = true;
break;
}
if (comp)
Image.DrawBitmapComposited(sprlst[i].Image, new Point(sprlst[i].X - left, sprlst[i].Y - top));
else
Image.DrawBitmap(sprlst[i].Image, new Point(sprlst[i].X - left, sprlst[i].Y - top));
}
}

public static Sprite LoadChaotixSprite(string filename) { return LoadChaotixSprite(File.ReadAllBytes(filename), 0); }
Expand Down
6 changes: 3 additions & 3 deletions SonLVLAPI/LevelData.cs
Expand Up @@ -2598,7 +2598,7 @@ public static Sprite MapTileToBmp(byte[] art, MappingsTile map, int startpal)
{
for (int y = 0; y < map.Height; y++)
{
pcbmp.DrawBitmapComposited(
pcbmp.DrawBitmap(
TileToBmp8bpp(art, map.Tile.Tile + ti, (map.Tile.Palette + startpal) & 3),
x * 8, y * 8);
ti++;
Expand Down Expand Up @@ -2639,7 +2639,7 @@ public static void RedrawBlock(int block, bool drawChunks)
);
}
}
CompBlockBmpBits[block].DrawBitmapComposited(BlockBmpBits[block][0], Point.Empty);
CompBlockBmpBits[block].DrawBitmap(BlockBmpBits[block][0], Point.Empty);
CompBlockBmpBits[block].DrawBitmapComposited(BlockBmpBits[block][1], Point.Empty);
BlockBmps[block][0] = BlockBmpBits[block][0].ToBitmap(BmpPal);
BlockBmps[block][1] = BlockBmpBits[block][1].ToBitmap(BmpPal);
Expand Down Expand Up @@ -2708,7 +2708,7 @@ public static void RedrawChunk(int chunk)
}
}
}
CompChunkBmpBits[chunk].DrawBitmapComposited(ChunkBmpBits[chunk][0], Point.Empty);
CompChunkBmpBits[chunk].DrawBitmap(ChunkBmpBits[chunk][0], Point.Empty);
CompChunkBmpBits[chunk].DrawBitmapComposited(ChunkBmpBits[chunk][1], Point.Empty);
ChunkBmps[chunk][0] = ChunkBmpBits[chunk][0].ToBitmap(BmpPal);
ChunkBmps[chunk][1] = ChunkBmpBits[chunk][1].ToBitmap(BmpPal);
Expand Down

0 comments on commit e3b1c04

Please sign in to comment.