From ee55ffe097e6ab3b41dca8539fe5aa3325ab8084 Mon Sep 17 00:00:00 2001 From: chrisf Date: Sat, 14 Jul 2007 15:11:07 +0000 Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1256 993157c7-ee19-0410-b2c4-bb4e9862e678 --- OpenRa.BlockCacheVisualizer/Form1.Designer.cs | 2 +- OpenRa.BlockCacheVisualizer/Form1.cs | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/OpenRa.BlockCacheVisualizer/Form1.Designer.cs b/OpenRa.BlockCacheVisualizer/Form1.Designer.cs index a525d53002..19af6ba754 100644 --- a/OpenRa.BlockCacheVisualizer/Form1.Designer.cs +++ b/OpenRa.BlockCacheVisualizer/Form1.Designer.cs @@ -33,7 +33,7 @@ namespace OpenRa.BlockCacheVisualizer // // flowLayoutPanel1 // - this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.BackColor = System.Drawing.SystemColors.MenuHighlight; this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; diff --git a/OpenRa.BlockCacheVisualizer/Form1.cs b/OpenRa.BlockCacheVisualizer/Form1.cs index d4ad332eed..fb60afd397 100644 --- a/OpenRa.BlockCacheVisualizer/Form1.cs +++ b/OpenRa.BlockCacheVisualizer/Form1.cs @@ -15,6 +15,10 @@ namespace OpenRa.BlockCacheVisualizer public Form1() { InitializeComponent(); + ClientSize = new Size(525,525); + FormBorderStyle = FormBorderStyle.FixedSingle; + MaximizeBox = false; + Text = "PNG Block Cache Visualizer"; Visible = true; OpenFileDialog d = new OpenFileDialog(); @@ -24,6 +28,8 @@ namespace OpenRa.BlockCacheVisualizer if (DialogResult.OK != d.ShowDialog()) return; + + string filename = d.FileName; string palname = Path.GetDirectoryName(filename) + "\\palette-cache.png"; @@ -39,6 +45,7 @@ namespace OpenRa.BlockCacheVisualizer pb.SizeMode = PictureBoxSizeMode.AutoSize; pb.Image = b; + pb.BackColor = Color.White; flowLayoutPanel1.Controls.Add(pb); } @@ -52,18 +59,18 @@ namespace OpenRa.BlockCacheVisualizer return (hax & 0xff) | (hax >> 8); } + static BitmapData Lock(Bitmap b, ImageLockMode mode) + { + return b.LockBits(new Rectangle(new Point(), b.Size), mode, b.PixelFormat); + } + Bitmap ExtractChannelToBitmap(Bitmap src, Bitmap pal, uint mask) { Bitmap dest = new Bitmap(src.Width / 2, src.Height / 2, pal.PixelFormat); - BitmapData destData = dest.LockBits(new Rectangle(new Point(), dest.Size), ImageLockMode.WriteOnly, - dest.PixelFormat); - - BitmapData paletteData = pal.LockBits(new Rectangle(new Point(), pal.Size), ImageLockMode.ReadOnly, - pal.PixelFormat); - - BitmapData srcData = src.LockBits(new Rectangle(new Point(), src.Size), ImageLockMode.ReadOnly, - src.PixelFormat); + BitmapData destData = Lock(dest, ImageLockMode.WriteOnly); + BitmapData paletteData = Lock(pal, ImageLockMode.ReadOnly); + BitmapData srcData = Lock(src, ImageLockMode.ReadOnly); int destStride = destData.Stride/4; int srcStride = srcData.Stride/4;