Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


[java] pixelGrabber and grabPixels


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 ao   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 September 2000 - 04:15 AM

I have a background image where I draw all my graphics too, I would like to grab all the pixels of that background image and put them into an array so I can manipulate them. Now, the problem is grabPixels only works the first time I call it, after that it doesn''t grab pixels. It only works if I do this every loop: pg = new PixelGrabber( backBuffer, 0, 0, 320, 240, bbPixels, 0, 320 ); try { pg.grabPixels(); } catch( InterruptedException ie ) { System.out.println( "Couldn''t grab em" ); } I really don''t want to create a new PixelGrabber object every time through the loop, it is slow... Shouldn''t subsequent calls to grabPixels work and refill the bbPixels array with the current data? Thanks, ao

Sponsor:

#2 Jim_Ross   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 September 2000 - 04:51 AM

quote:
Original post by ao
Shouldn't subsequent calls to grabPixels work and refill the bbPixels array with the current data?




That is what happens, although sometimes you have to wait for the Image to send all its pixels.


try {
if ( ! pg.grabPixels() ) {
System.out.println("Grab aborted");
return;
}
} catch (InterruptedException e) {
System.out.println("Grab Timed out: \n" + e.printStackTrace());
}



Edited by - Jim_Ross on September 21, 2000 11:52:52 AM

#3 ao   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 September 2000 - 05:14 AM

Well, ya see, thats the strange thing. I checked the return value of pg.grabPixels() it is true... And according to the documentation that means:

Returns:
true if the pixels were successfully grabbed, false on abort, error or timeout

Well, I know the pixels weren''t successfully grabbed. Because an image that I drew on the backbuffer just before calling grabPixels isn''t there. But it does appear ( in the bbPixel array ) if I put the:

pg = new PixelGrabber( backBuffer, 0, 0, 320, 240, bbPixels, 0, 320 );

code in there. So I know the data is there, grabPixels just isn''t grabbing it.

hmmmm,
ao





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS