Skip to content

Commit

Permalink
Correct loaded presets if they have impossible values.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbradsmith committed Nov 6, 2024
1 parent 6321d1a commit 513b21f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
29 changes: 20 additions & 9 deletions BinxelviewForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,22 @@ public bool loadFile(string path)
int linecount = 0;
try
{
// version
// endian chunky
// bpp width height
// (stride byte) pixel row next
// (stride bit) pixel row next
// (stride auto) pixel row next
// plane X size byte bit
// plane Y size byte bit
// (bpp * bit stride) byte bit
// VERSION 3
// version
// endian chunky twiddle
// bpp width height
// (stride byte) pixel row next
// (stride bit) pixel row next
// (stride auto) pixel row next
// (tile stride X) size byte bit
// (tile stride Y) size byte bit
// (bpp * bit stride) byte bit

// VERSION 2
// same as VERSION 3 without twiddle

// VERSION 1
// same as VERSION 2 but tile stride was relative to pixel stride, instead of absolute

name = Path.GetFileNameWithoutExtension(path);

Expand All @@ -238,12 +245,16 @@ public bool loadFile(string path)
chunky = int.Parse(ls[1]) != 0;
if (version >= 3) twiddle = int.Parse(ls[2]);
else twiddle = 0;
if (twiddle < 0 || twiddle > 2) twiddle = 0;

l = tr.ReadLine();
ls = l.Split(' ');
bpp = int.Parse(ls[0]);
width = int.Parse(ls[1]);
height = int.Parse(ls[2]);
if (bpp < 0) bpp = 1;
if (width < 1) width = 1;
if (height < 1) height = 1;

l = tr.ReadLine();
ls = l.Split(' ');
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ Changes
1.6.6.0 (unreleased beta)
- Add PDB to release package to assist debugging.
- Fix initialization crash. #30
- Correct loaded presets if they have impossible values.

1.6.5.0 (2024-10-26)
- Option persistence, INI file save and load.
Expand Down

0 comments on commit 513b21f

Please sign in to comment.