• Advertisement

Archived

This topic is now archived and is closed to further replies.

[java] Drawing a frame from a image strip

This topic is 6265 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

At the moment i load the image strip(anywhere from 7 - 56 frames) using an image manager class. Then when some other class wants to get the image, it gets a reference to the image(every frame) and then use Image.drawImage(Image, sx1,sy1,sx2,sy2,dx1,dy1,dx2,dy2) to draw the current frame.I have tested and tested my code and found this is where the slow fps is coming from so my questions are: 1) Whats a better alternative to drawImage? 2) Is my image manager class a good idea(ie getting a reference every frame, probably not a good idea)? 3) Any other suggestions?? Thanks, T.J

Share this post


Link to post
Share on other sites
Advertisement
You could eliminate the need for all that clipping by cutting each frame out in an own Image and then just draw them with a;

g.drawImage(buf, x,y, null);

I don''t know if this is faster, but i sure think so...


/ dr-m

Share this post


Link to post
Share on other sites
Assuming you are not doing this alreay you could copy your imapge strip to an optimized image format by using the...

component.createImage(width,height)

and the copy your image to that and use it insted of your loaded image. The problem with this is it does not work for semi-transparent images. So if you don''t need transparency Just make a bunch of companent.createImage(..)''s and drawImage(Image,sx,sy....) into them. Them your drawing should speed up.

If not you can check my previous thread about drawing speed for alternatives to drawImage, but they are not for the faint of heart. I''m working on an abstraction layer that should make it easier.

Share this post


Link to post
Share on other sites
hmmmmmm
I thought there were benefits
to image clipping...
but I really don''t know anything
and if its slowing down your FPS
then I guess you need to ditch it

Share this post


Link to post
Share on other sites

  • Advertisement