Re: I have an issue with an image getting corrupted upon scroll in a panel.
- From: "MurdockSE" <murdock@xxxxxxxxx>
- Date: 20 Jul 2006 18:11:54 -0700
I may just use this method and just rebuild a new image each time you
select the map or after you click the mouse on the picturebox to add a
new 'division'
http://www.bobpowell.net/modifyImage.htm
I wanted to save a new image file of the saves regardless. My only
problem with this is that the jpeg sometimes looks more compressed. Is
there a way to force no compression upon save?
Murdock
MurdockSE wrote:
Hello all. I've followed some very nice articles at c-sharp corner and
the code project to come up with an overlayed map image, with military
unit icons on top (as well as text demarking the division name). My
problem is that the images are so large ; I wanted to put them into a
panel for scrolling capabilities. My issue now is that after painting
the images (one on top of the other, etcetera), the image gets
corrupted and disappears upon scrolling within a panel.
Layout:
Form { pictureBox1 inside a Panel 1 }.
I am using the following code upon selecting a new map name in a
combobox3:
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
IniFile INI = new IniFile(@"c:\\data\TM.ini");
string MapFileDir = INI.IniReadValue("Main", "MapDir");
string MapName = INI.IniReadValue("Main",
this.comboBox3.Text);
string[] MapNameArray = MapName.Split(',');
string ImageName = MapNameArray[0].ToString();
//pictureBox1.ImageLocation = MapFileDir + @"\"+ImageName;
Graphics g = pictureBox1.CreateGraphics();
g.Clear(this.BackColor);
Image curImage = Image.FromFile(MapFileDir + @"\" +
ImageName);
Image curImage2 =
Image.FromFile(@"c:\data\maps\G-Armour-mil.gif");
g.DrawImage(curImage, 0, 0, curImage.Width,
curImage.Height);
g.DrawImage(curImage2, 100, 100, curImage2.Width,
curImage2.Height);
SolidBrush mySolidBrush = new SolidBrush(Color.Black);
g.DrawString("1st", new Font("Verdana", 8), mySolidBrush,
new RectangleF(100, 89, 105, 98));
g.Dispose();
}
It works fine, and draws the images and text appropriately, but the
pictureBox1 is inside a panel1 for scrolling purposes. When I scroll
the panel, the image corrupts. Is there a way to redraw the image/s as
the panel is scrolling and keep appropriate x,y pixel overlays?
Here is a picture of the working program:
http://seow.trianglesimsociety.org/Captured.JPG
When i scroll the image using the scroll bars, the image corrupts, but
the icon stays in it's appropriate place. In other words, I'm only able
to draw into the visible area. If I move out of that initial visible
area, the image crops off and or disappears entirely.
My thoughts:
If there is no way around this picturebox in a panel redraw issue ;
then Im thinking of making an entirely new JPG out of the combination
of everything I've created above. Is there a way to do that invisibly,
save the file to a new name, then set the pictureBox1.imagelocation to
that new file? I may want this functionality anyhow after the final
mission template is created. Just FYI, in case you are wondering what
this is for ; This is for use as a template maker for the following
open source tool http://seow.sourceforge.net/
Thanks for any pointers you may be able to provide on this. I'm really
loving programming in c#. Its gotten me excited to program again.
Regards,
Peter Robbins
Freelance Programmer C#/PHP
.
- Follow-Ups:
- Re: I have an issue with an image getting corrupted upon scroll in a panel.
- From: Bob Powell [MVP]
- Re: I have an issue with an image getting corrupted upon scroll in a panel.
- References:
- Prev by Date: Re: GraphicsPath.IsVisible broken?
- Next by Date: Re: Font not found Exception
- Previous by thread: I have an issue with an image getting corrupted upon scroll in a panel.
- Next by thread: Re: I have an issue with an image getting corrupted upon scroll in a panel.
- Index(es):
Relevant Pages
|