Skip to content

Commit

Permalink
File reading actually works now
Browse files Browse the repository at this point in the history
  • Loading branch information
itisrazza committed Aug 30, 2019
1 parent d2d775c commit b6a4353
Show file tree
Hide file tree
Showing 6 changed files with 355 additions and 50 deletions.
90 changes: 48 additions & 42 deletions VGAPainter/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions VGAPainter/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ private void OpenImage_Click(object sender, EventArgs e)
if (result != DialogResult.OK) return;

// open the image
Stream file = new FileStream(saveTgr.FileName, FileMode.Open);
Stream file = new FileStream(openTgr.FileName, FileMode.Open);
BinaryReader br = new BinaryReader(file, Encoding.ASCII);

// first check the header
char[] header = br.ReadChars(FileHeader.Length);
if (header != FileHeader.ToCharArray()) throw new Exception("Invalid format");
if (new string(header) != FileHeader) throw new Exception("Invalid format");

// read the width and height
bmWidth = br.ReadUInt16();
Expand All @@ -299,6 +299,8 @@ private void OpenImage_Click(object sender, EventArgs e)

// done
br.Close();

Redraw();
}

private void SaveImage_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -352,6 +354,7 @@ private void DoMouse(int mouseX, int mouseY)

// pre-calc image offset
int offset = mouseY * bmWidth + mouseX;
if (offset < 0 || offset >= bmData.Length) return;

switch (drawMode)
{
Expand Down Expand Up @@ -408,7 +411,8 @@ private void CanvasBox_MouseLeave(object sender, EventArgs e)

private void AboutToolStripMenuItem_Click(object sender, EventArgs e)
{

MessageBox.Show("VGAPainter by thegreatrazz\n" +
"https://github.com/thegreatrazz/VGAPainter");
}

private void Exit_Click(object sender, EventArgs e)
Expand Down
Loading

0 comments on commit b6a4353

Please sign in to comment.