RE: System.Drawing.Bitmap to java.awt.Image?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: alex (alex_at_discussions.microsoft.com)
Date: 01/10/05


Date: Mon, 10 Jan 2005 07:17:10 -0800

Well here's one approach that works:

1. in the projects's .resx file, change the type of the .gif file from
System.Drawing.Bitmap to System.Byte[]

2. Use ResourceManager.GetObject() to get the .gif data as ubyte[]:

   ubyte[] b = (ubyte[]) resMgr.GetObject("MyGif");

3. Create java.awt.Image from .gif data:

   byte[] b2 = new byte[b.length];
   for (int i=0; i < b.length; ++i)
       b2[i] = (byte) b[i];

   Image image = Toolkit.getDefaultToolkit().createImage(b2);