[java] Drawing a frame from a image strip

Started by
2 comments, last by tjbrosna 23 years, 4 months ago
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
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
/ dr-m
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.
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
"do you like my helmut?"-yoghurt

This topic is closed to new replies.

Advertisement