Re: I have an issue with an image getting corrupted upon scroll in a panel.



The GDI+ FAQ shows you how to save without compression. JPEG compression,
which is lossy, progressively mucks up a pictire the more you load / save
cycle it.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



"MurdockSE" <murdock@xxxxxxxxx> wrote in message
news:1153444314.917814.49540@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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



.



Relevant Pages

  • Re: GDI+ Performance Question
    ... I've been reading alot about how GDI+ does not ... > the scrolling. ... > render on the screen, though most likely, I'll only need to render at most ... I either use another .NET control and draw to that ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: GDI+ Performance Question
    ... what is this Canvas object that you are using for drawing? ... I've been reading alot about how GDI+ does not ... The rendering algorithm is pretty sound, it'll only render the parts of the score that need to be. ... For performance reasons, I'm drawing to a bitmap and during scrolling, I'm actually only rendering parts of the bitmap, in order to keep performance under control, but I don't like that approach. ...
    (microsoft.public.dotnet.framework.drawing)
  • GDI+ Performance Question
    ... I've been reading alot about how GDI+ does not ... the scrolling. ... When I scroll up or down, it consumes 100% of my CPU to draw ... render on the screen, though most likely, I'll only need to render at most ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: GDI+ Performance Question
    ... > Sorry, don't know about GDI+ ... Actually, in a .NET UserControl, the scrolling functionality is quite ... then what notes are visible and render them. ... I pre-render all my entities to a bitmap for scrolling and ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Flowlayout, JPanel and JScrollPane: Scrolling vertically impossible?
    ... >> JScrollPane using FlowLayout. ... >> enable wrapping, and when components inside the panel go out of view, ... > scrolling). ... > (And therefore the preferredSize value returned by the panel would ...
    (comp.lang.java.gui)