Skip to content

Commit

Permalink
✨ Add convenient constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
pleonex committed Dec 6, 2023
1 parent c0f3d21 commit 8e79226
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/Texim/Compressions/Nitro/MapDecompression.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 SceneGate
// Copyright (c) 2021 SceneGate

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -30,12 +30,20 @@ public class MapDecompression :
{
private readonly System.Drawing.Size tileSize;
private readonly IScreenMap map;
private readonly int outOfBoundsIndex = -1;
private readonly int outOfBoundsIndex;

public MapDecompression(IScreenMap map)
{
ArgumentNullException.ThrowIfNull(map);

this.map = map;
tileSize = new System.Drawing.Size(8, 8);
outOfBoundsIndex = -1;
}

public MapDecompression(MapDecompressionParams parameters)
{
if (parameters == null)
throw new ArgumentNullException(nameof(parameters));
ArgumentNullException.ThrowIfNull(parameters);

tileSize = parameters.TileSize;
map = parameters.Map;
Expand Down
14 changes: 13 additions & 1 deletion src/Texim/Formats/IndexedImage2Bitmap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 SceneGate
// Copyright (c) 2021 SceneGate

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -32,6 +32,18 @@ public class IndexedImage2Bitmap : IConverter<IIndexedImage, BinaryFormat>
{
private readonly IndexedImageBitmapParams parameters;

public IndexedImage2Bitmap(IPalette palette)
{
ArgumentNullException.ThrowIfNull(palette);
parameters = new() { Palette = palette };
}

public IndexedImage2Bitmap(IPaletteCollection palettes)
{
ArgumentNullException.ThrowIfNull(palettes);
parameters = new() { Palettes = palettes };
}

public IndexedImage2Bitmap(IndexedImageBitmapParams parameters)
{
ArgumentNullException.ThrowIfNull(parameters);
Expand Down

0 comments on commit 8e79226

Please sign in to comment.