---
title: "Simple Conversion (System.Drawing Interop)"
canonical: https://www.graphicsmill.com/samples/Interoperability/SystemDrawingInteroperability/SimpleConversion_cs
product: "Graphics Mill"
source: "Interoperability/SystemDrawingInteroperability/SimpleConversion.cs"
---

# Simple Conversion (System.Drawing Interop)

Converts Aurigma.GraphicsMill.Bitmap to System.Drawing.Bitmap and vice versa.

## Instruction

Write a C# program that demonstrates simple GraphicsMill to System.Drawing interop by loading "Copenhagen_RGB.jpg" as GraphicsMill Bitmap, casting directly to System.Drawing.Bitmap for legacy processing (watermark application), casting back to GraphicsMill Bitmap to copy pixels without conversion, and saving the result as "SimpleConversion.jpg" using the Save method.

## Code Snippet

```csharp
// Imagine that you have a legacy application which works with System.Drawing.Bitmap,
// and you want to integrate it with Graphics Mill.
using (var gmBitmap1 = new Bitmap("Copenhagen_RGB.jpg"))
using (var sdBitmap = (System.Drawing.Bitmap)gmBitmap1)
{
    // Here we modify System.Drawing.Bitmap
    Utils.ApplyWatermark(sdBitmap);

    // If all you need is to copy pixels, just cast your System.Drawing.Bitmap
    // to Aurigma.GraphicsMill.Bitmap.
    using (var gmBitmap2 = (Bitmap)sdBitmap)
    {
        gmBitmap2.Save("SimpleConversion.jpg");
    }
}
```

## Explanation

Below is a C# code sample that shows basic GraphicsMill and System.Drawing interop for RGB images:

The code demonstrates seamless pixel data sharing between GraphicsMill and System.Drawing via direct casting without copying or conversion, enabling legacy System.Drawing processing (watermarking) within GraphicsMill workflows. The round-trip preserves original pixel data, color profile, and metadata through the cast operations, making it the simplest integration pattern for RGB images where no color space conversion or metadata transfer is required. This approach offers zero-overhead interoperability for applications already using both libraries.

## Tags

- [Bitmap](<https://www.graphicsmill.com/samples/tags/bitmap_md>): Working with images via the Bitmap API
- [Interoperability](<https://www.graphicsmill.com/samples/tags/interoperability_md>): Interop with GDI+ and other libraries
- [Watermark](<https://www.graphicsmill.com/samples/tags/watermark_md>): Adding text or image watermarks

## Input

- [Copenhagen\_RGB.jpg](<https://www.graphicsmill.com/samples/Interoperability/compiled/Debug/Copenhagen_RGB_jpg>) (preview)

## Output

- [SimpleConversion.jpg](<https://www.graphicsmill.com/samples/Interoperability/compiled/Debug/SimpleConversion_jpg>) (preview)

