Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Is graphics2d.drawImage(image, 0, 0, w, h, null) an asynchronous operation?

Reply
Thread Tools

Is graphics2d.drawImage(image, 0, 0, w, h, null) an asynchronous operation?

 
 
Wolfgang
Guest
Posts: n/a
 
      02-10-2004
Assume I have an image 'img'.
Rreading the image from a file, I made sure I really have the entire
image available by using a MediaTracker.

Now I want to print the image into a BufferedImage using drawImage on
the graphics object of the BufferedImage. The question: is this use
of drawImage a asynchronous operation?

So here is what I want to do:

bufImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics2d. = bufImage.createGraphics();
// get and image named 'img' here;
// getting the image is asynchronous
// so use a MediaTracker to make sure it has arrived.

// Now that I am sure I have the complete image 'img', I draw it
graphics2d.drawImage(img, 0, 0, w, h, null);
System.out.println("Question: Am I guranteed at this point to have");

System.out.println(" 'img' completely in the buffered image?");
System.out.println(" Or did drawImage go off on a thread while I");
System.out.println(" continue parallel execution?");

If graphics2d.drawImage(image, 0, 0, w, h, null) is asynchronous, is
there a way to wait for it to complete (like a MediaTracker for
loading an image from disk)?

Thanks,

Wolfgang
Santa Barbara, CA
 
Reply With Quote
 
 
 
 
Knute Johnson
Guest
Posts: n/a
 
      02-10-2004
Wolfgang wrote:

> Assume I have an image 'img'.
> Rreading the image from a file, I made sure I really have the entire
> image available by using a MediaTracker.
>
> Now I want to print the image into a BufferedImage using drawImage on
> the graphics object of the BufferedImage. The question: is this use
> of drawImage a asynchronous operation?
>
> So here is what I want to do:
>
> bufImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
> Graphics2D graphics2d. = bufImage.createGraphics();
> // get and image named 'img' here;
> // getting the image is asynchronous
> // so use a MediaTracker to make sure it has arrived.
>
> // Now that I am sure I have the complete image 'img', I draw it
> graphics2d.drawImage(img, 0, 0, w, h, null);
> System.out.println("Question: Am I guranteed at this point to have");
>
> System.out.println(" 'img' completely in the buffered image?");
> System.out.println(" Or did drawImage go off on a thread while I");
> System.out.println(" continue parallel execution?");
>
> If graphics2d.drawImage(image, 0, 0, w, h, null) is asynchronous, is
> there a way to wait for it to complete (like a MediaTracker for
> loading an image from disk)?
>
> Thanks,
>
> Wolfgang
> Santa Barbara, CA


Yes.

That being said, why don't you use ImageIO.read() to get a BufferedImage
in the first place?

--

Knute Johnson
email s/nospam/knute/
Molon labe...
 
Reply With Quote
 
 
 
 
Wolfgang
Guest
Posts: n/a
 
      02-10-2004
Knute Johnson <(E-Mail Removed)> wrote in message news:<8aceb36416cf3b38433f89c09b565357@news.1usene t.com>...
> Wolfgang wrote:
>
> > The question: is this use
> > of drawImage a asynchronous operation?
> >

>
> Yes.
>
> That being said, why don't you use ImageIO.read() to get a BufferedImage
> in the first place?


I wanted to know because I use
graphics2d.drawImage(img, ...);
to make intermediate copies of a buffered image objects (for temporary
safe keeping) and my GUI may depend on one of those intermediate
copies. I copy like this

graphics2dOfBufferedImage_temp.drawImage(bufferedI mageToCopy, ...);

Perhaps you know a better way of making copies of a buffered Image.
If so, please tell me.

Thanks,
Wolfgang
 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      02-10-2004
Wolfgang wrote:
> Knute Johnson <(E-Mail Removed)> wrote in message news:<8aceb36416cf3b38433f89c09b565357@news.1usene t.com>...
>
>>Wolfgang wrote:
>>
>>
>>>The question: is this use
>>>of drawImage a asynchronous operation?
>>>

>>
>>Yes.
>>
>>That being said, why don't you use ImageIO.read() to get a BufferedImage
>>in the first place?

>
>
> I wanted to know because I use
> graphics2d.drawImage(img, ...);
> to make intermediate copies of a buffered image objects (for temporary
> safe keeping) and my GUI may depend on one of those intermediate
> copies. I copy like this
>
> graphics2dOfBufferedImage_temp.drawImage(bufferedI mageToCopy, ...);
>
> Perhaps you know a better way of making copies of a buffered Image.
> If so, please tell me.
>
> Thanks,
> Wolfgang


Wolfgang:

I don't know what the performance costs of doing that are. It is
probably as efficient as any other method of copying. You could try
experimenting with BufferedImage.getRGB() and comparing the two methods
for temporary storage.

--

Knute Johnson
email s/nospam/knute/
Molon labe...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asynchronous counter an Xilinx FPGA for a newbie Georges Konstantinidis VHDL 12 08-04-2006 04:42 AM
Will this "asynchronous handshaking" feasible in real circuits? HUANG Huan VHDL 2 02-24-2004 09:07 PM
Coding an Asynchronous state machine Jamie VHDL 13 10-23-2003 08:41 AM
Send a PULSE on input change, asynchronous Jamie VHDL 4 10-22-2003 06:57 AM
asynchronous design Amir VHDL 3 10-10-2003 02:10 PM



Advertisments