Google Gruplar, artık yeni Usenet gönderilerini veya aboneliklerini desteklememektedir. Geçmişteki içerikler görüntülenebilir kalmaya devam edecek.

More graphics...

0 görüntüleme
İlk okunmamış mesaja atla

tca...@nycm.com

okunmadı,
7 Tem 1998 03:00:007.07.1998
alıcı

In the below example, I create an Image using a utility class of my own,
and then draw that image. Previously I had just assigned the new image
that util created directly to save_img (my off-screen image object) but
then I discovered that you cannot call getGraphics on an Image unless it
was created with the createImage(w,h) method. Anyways, the created image
does get drawn, but when I call createImage on this (my canvas) it saves
a blank (not drawn into) image. How can I save my temp image into save_img?

Image temp = util.createImage(s);
Graphics g = this.getGraphics();
g.drawImage(temp,0,0,this);
g.dispose();
save_img = this.createImage(canvas_width,canvas_height);

Do I need to mess around with an Image filter? They are so slow...

Thanks for any hints...
Tom
tca...@nycm.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

Franklin Simmons

okunmadı,
9 Tem 1998 03:00:009.07.1998
alıcı
If I understand your problem/question you'll need to use PixelGrabber to "save"
the image and MemoryImageSource to construct a new Image object.
......
Image temp = util.createImage(s);
.....
Image save_img = null;
try
{
int w = temp.getWidth(null);
int h = temp.getHeight(null);
int [] pix = new int [ w * h ];
PixelGrabber pg = new PixelGrabber ( temp, 0,0,x,y, new int [ w * h ],
0, w );
pg.grabPixels(); // may throw InterruptedException
Image save_img = createImage( new MemoryImageSource (w,h,pix,0,w);
}
catch ( InterruptedException ie1 )
{
// handle the exception, noting that save_img == null
}
.....
However, I'm not quite sure what your code sample is accomplishing (below). You
have a reference to the Image object temp; why do you need two copies of the
_same_ image? If you need to keep a list of images just place them in a data
struture and work from there.

And why call dispose()?

Franklin

Gordon Waiter

okunmadı,
14 Tem 1998 03:00:0014.07.1998
alıcı
This is the code I use to draw an image to Memory

Image offScreenImage = this.createImage(rawWidth,rawHeight);
Graphics offScreenContext = offScreenImage.getGraphics();

offScreenContext.drawImage(image1,0,0,256,256,this);

then in the paint method,.

g.drawImage(offScreenImage,0,0,this);

Hope this helps.

Gordon.


tca...@nycm.com

okunmadı,
14 Tem 1998 03:00:0014.07.1998
alıcı
Sorry I havent replied in a while. I was away. The reason I have two Image
objects is because the first (temp) is created from a MemoryImageSource. I
cannot call getGraphics on it (and I need to to do some painting in other
methods). Therefore I paint the temp image on the component and then try to
create a saved image from it that I can later make the call to getGraphics.
Below is the error message I get if i try it with just one Image.

Exception occurred during event dispatching:
java.lang.IllegalAccessError: getGraphics() only valid for images created
with createImage(w, h)
at sun.awt.windows.WImage.getGraphics(WImage.java:45)
at MotDrawCanvas.mouseDrag(MotDrawCanvas.java:102)
at java.awt.Component.handleEvent(Component.java:2356)
at java.awt.Component.postEvent(Component.java:1884)
at java.awt.Component.dispatchEventImpl(Component.java:1776)
at java.awt.Component.dispatchEvent(Component.java:1704)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)

In article <35A4F5BE...@cyberatl.net>,

0 yeni ileti