0

I am trying to create an image in memory so that I can combine two or more transparent images and present them as a bitmap in a picture box in a user control.

my opening code :

System.Drawing.Image Beat = new System.Drawing.Image()

results in "Cannot create an instance of the abstract class or interface 'System.Drawing.Image'"

can anyone tell me why?

I am using the following directives (so to rule out ambiguity)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

many thanks

Dan

2 Answers2

1

System.Drawing.Image is abstract, just as the compiler informed you. You need to choose a "concrete" implementation of Image, like Bitmap.

Tergiver
  • 14,171
  • 3
  • 41
  • 68
  • Thanks and Sorry, was referencing code posted on this site http://stackoverflow.com/questions/2479133/how-can-i-overlay-one-image-onto-another ... on closer inspection this is a WPF example so I can assume it is different for winforms? –  Jun 08 '12 at 18:00
  • WPF doesn't use System.Drawing.dll, it would be `BitmapSource` in WPF (I believe, I'm not a WPF expert). WinForms uses System.Drawing.dll where `Bitmap` can be found. – Tergiver Jun 08 '12 at 18:06
  • Ok, I am going to assume that the link I posted above only works on WPF and that in WPF you can create an Image in the manner described but that in WinForms I have to use Bitmap instead. all of this in the spirit of trying to get real image layers and transparency working! ;-) thanks for your help D –  Jun 08 '12 at 18:12
1

System.Drawing.Image is an abstract class which means it cannot be instantiated. You need to create an instance of a concrete class that derives from it, like System.Drawing.Bitmap or System.Drawing.Imaging.Metafile.

Seth Flowers
  • 8,990
  • 2
  • 29
  • 42