Click here to Skip to main content
15,868,141 members
Home / Discussions / C#
   

C#

 
GeneralClass Circular References Pin
Abner Mallidy25-Apr-04 18:40
Abner Mallidy25-Apr-04 18:40 
GeneralRe: Class Circular References Pin
Jeff Varszegi25-Apr-04 19:55
professionalJeff Varszegi25-Apr-04 19:55 
Questionhow to draw on a bitmap? Pin
lowiq25-Apr-04 18:08
lowiq25-Apr-04 18:08 
AnswerRe: how to draw on a bitmap? Pin
CWIZO25-Apr-04 21:25
CWIZO25-Apr-04 21:25 
GeneralRe: how to draw on a bitmap? Pin
lowiq25-Apr-04 21:58
lowiq25-Apr-04 21:58 
GeneralRe: how to draw on a bitmap? Pin
Heath Stewart26-Apr-04 3:08
protectorHeath Stewart26-Apr-04 3:08 
GeneralRe: how to draw on a bitmap? Pin
lowiq26-Apr-04 19:48
lowiq26-Apr-04 19:48 
GeneralRe: how to draw on a bitmap? Pin
Heath Stewart27-Apr-04 2:49
protectorHeath Stewart27-Apr-04 2:49 
You'll need to save myBitmap to a stream as a different format (the easiest way, though other ways exist - see the .NET Framework SDK for more information about the Bitmap class). You can do this by creating a MemoryStream, saving the Bitmap as a different format, and then get a Graphics object from that:
using (Bitmap myBitmap = new Bitmap(@"C:\...\GaugeTime.gif"))
{
  using (MemoryStream ms = new MemoryStream())
  {
    myBitmap.Save(ms, ImageFormat.Bmp);
    ms.Seek(0, SeekOrigin.Begin);
    using (Bitmap newBitmap = new Bitmap(ms))
    {
      using (Graphics g = Graphics.FromImage(newBitmap))
      {
        // Draw in your image and save it to a new file or something.
      }
    }
  }
}
The various using statements just dispose the object when it falls out of scope - even if an Exception is thrown for some reason. Each using statement compiles to the following:
using (Bitmap bmp = new Bitmap(32, 32))
{
  // ...
}
// Compiles to...
Bitmap bmp = new Bitmap(32, 32);
try
{
  // ...
}
finally
{
  if (bmp != null) bmp.Dispose();
}


 

Microsoft MVP, Visual C#
My Articles
GeneralRe: how to draw on a bitmap? Pin
lowiq27-Apr-04 3:47
lowiq27-Apr-04 3:47 
GeneralFormula Pin
DucLinh25-Apr-04 15:39
DucLinh25-Apr-04 15:39 
GeneralRe: Formula Pin
Nick Parker25-Apr-04 15:53
protectorNick Parker25-Apr-04 15:53 
GeneralRe: Formula Pin
Werdna25-Apr-04 17:19
Werdna25-Apr-04 17:19 
GeneralRe: question Pin
Nick Parker25-Apr-04 15:39
protectorNick Parker25-Apr-04 15:39 
GeneralRe: question Pin
Steve McLenithan25-Apr-04 16:24
Steve McLenithan25-Apr-04 16:24 
GeneralRe: question Pin
Heath Stewart25-Apr-04 17:52
protectorHeath Stewart25-Apr-04 17:52 
GeneralRe: question Pin
Steve McLenithan26-Apr-04 6:38
Steve McLenithan26-Apr-04 6:38 
GeneralRe: question Pin
Nick Parker25-Apr-04 17:45
protectorNick Parker25-Apr-04 17:45 
GeneralRe: question Pin
osto25-Apr-04 16:53
osto25-Apr-04 16:53 
GeneralcheckedListBox Line Spacing Pin
interlocked25-Apr-04 13:42
interlocked25-Apr-04 13:42 
GeneralRe: checkedListBox Line Spacing Pin
Heath Stewart25-Apr-04 17:50
protectorHeath Stewart25-Apr-04 17:50 
Generaldates reminder from database Pin
kings_125-Apr-04 13:30
kings_125-Apr-04 13:30 
GeneralRe: dates reminder from database Pin
Heath Stewart25-Apr-04 17:44
protectorHeath Stewart25-Apr-04 17:44 
GeneralRe: dates reminder from database Pin
kings_126-Apr-04 2:09
kings_126-Apr-04 2:09 
GeneralRe: dates reminder from database Pin
Heath Stewart26-Apr-04 3:02
protectorHeath Stewart26-Apr-04 3:02 
GeneralWeb control Pin
osto25-Apr-04 9:22
osto25-Apr-04 9:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.