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

From: George Birbilis [MVP J#] [9880] (birbilis_at_kagi.com)
Date: 01/27/05


Date: Fri, 28 Jan 2005 00:42:32 +0200


> Oops, I' wrong. The J# suppUI lib does NOT contain
> java.awt.image.BufferedImage

no, but according to J# team the java.awt.Image implementation that you get
from <Canvas>.getImage (hope I remember the method OK) is an offscreen image

in Java1.1.x [maybe at Java2 too] that method needed your component to first
be added to a containment hierarchy that has a native peer [a window etc.]
as the ultimate grand-grand-...-parent

so try making a java.awt.Canvas, call getImage on it, then call getGraphics
on that image. Do remember to Dispose/Destroy any Graphics objects and
Images you create yourself (they have appropriate methods). BTW, never
destroy the Graphics object you get passed as a param to a "paint" method,
that's handled by the JVM (oops, by J# libs in the .NET case ;o)

if above stuff doesn't work (see blank image), try adding the Canvas to some
java.awt.Frame or java.awt.Window first, even if that one isn't displayed
(think you don't need to display it, just creating window/frame will make
necessery native peer). However this thing shouldn't be needed according to
some older discussion I had with J# team regarding adding BufferedImage
(having BI class would be cool anyway though)

cheers,
George

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
George Birbilis <birbilis@kagi.com>
Microsoft MVP J# for 2004, 2005
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ QuickTime controls (Delphi & ActiveX: VB, PowerPoint, .NET)
+ Plugs (InterProcess/Internet communication)
+ TranXform (VB6 form to ASP.net WebForm convertion)
http://www.kagi.com/birbilis
+ Robotics
http://www.mech.upatras.gr/~robgroup
........................................................................


Relevant Pages


Loading