Preformance With DrawImage!

ok am drawing this on my screen // this is backround for the 2d platformer btw

http://s7.postimg.org/4frzz3pi3/backround.png

but i don’t want to draw it all i only want to draw what the screen can see

for example here i want to only draw whats inside that red rectangle

http://s22.postimg.org/oy71dto9t/backround2.png

i got it working with tiles and stuff using a collision box but i have never done it with an full image

do i need to get the pixels that are colliding and so how do i do that?

What are u using?
OpenGL: change the texture coords
Java2D: Graphics.setClip(x, y, width, height)
Thats all that I know

hope this helps! :smiley:

Thanks so much! this is gonna make everything so much easier

so does it still load the pixels outside the clip?

I would guess so , its a clip function not a modified load function , if you are going to do something like this take a look at buffered rendering.

If you really care about performance move onto some framework that uses opengl.

But that does not really answer your question.

Why use setClip when the drawImage method does it for you?

[icode]drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)[/icode]

would you mind giving those varibles names, first time am doing this… with and image!

http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html#drawImage(java.awt.Image,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20java.awt.image.ImageObserver)