Jump to content

How to Select and Draw a Portion of a 512 x 512 Image


Eric
 Share

Recommended Posts

How can I select and draw a portion of an Image. I have a 1024 x 1024 Image that consists of various buttons and display parts,

 

Currently I use this code to Draw and Rotate an Image, but I am unsure how to select a section of my image to draw.

 

Function DrawAndRotateImage(itr:TTexture, Ax:Int, Ay:Int, Sx:Int, Sy:Int, Ir:Float)
       glMatrixMode(GL_TEXTURE)
       glLoadIdentity()
       glTranslatef(0.5,0.5,0)
       glRotatef(Ir,0,0,1)
       glTranslatef(-0.5,-0.5,0)
       glMatrixMode(GL_MODELVIEW)
       glEnable itr.Target()
       itr.Bind()
       itr.Clamp(1,1,1)
       DrawRect(Ax,Ay,Sx,Sy)
       glDisable(GL_TEXTURE_2D)
       glMatrixMode(GL_TEXTURE)
       glLoadIdentity()
       glMatrixMode(GL_MODELVIEW)
       glScalef(1,1,1) 
End Function

 

How can I add to this code to allow me to select a portion of the image.

 

Thanks for any help.

Eric

Link to comment
Share on other sites

  • 1 month later...

How can I select and draw a portion of an Image. I have a 1024 x 1024 Image that consists of various buttons and display parts,

 

Currently I use this code to Draw and Rotate an Image, but I am unsure how to select a section of my image to draw.

 

Function DrawAndRotateImage(itr:TTexture, Ax:Int, Ay:Int, Sx:Int, Sy:Int, Ir:Float)
       glMatrixMode(GL_TEXTURE)
       glLoadIdentity()
       glTranslatef(0.5,0.5,0)
       glRotatef(Ir,0,0,1)
       glTranslatef(-0.5,-0.5,0)
       glMatrixMode(GL_MODELVIEW)
       glEnable itr.Target()
       itr.Bind()
       itr.Clamp(1,1,1)
       DrawRect(Ax,Ay,Sx,Sy)
       glDisable(GL_TEXTURE_2D)
       glMatrixMode(GL_TEXTURE)
       glLoadIdentity()
       glMatrixMode(GL_MODELVIEW)
       glScalef(1,1,1) 
End Function

 

How can I add to this code to allow me to select a portion of the image.

 

Thanks for any help.

Eric

 

You need the UV coordinates of the area that you want to draw, then you need the GL_TEXTURE_CORD_ARRAY state and you need to use glTexCoordPointer, and glVertexPointer and glDrawArrays to draw your image.

You can use my little 2d library if you want, it gives alot of nice drawing functions, like frames of images like in blitzmax native 2d stuff, a fast image text system, and some other stuff that makes life easyer with 2d,bmx and leadwerks.

PM me if you want it

 

 

edit:ooops that thread is very old...

Whuts wroong?

Link to comment
Share on other sites

You need the UV coordinates of the area that you want to draw, then you need the GL_TEXTURE_CORD_ARRAY state and you need to use glTexCoordPointer, and glVertexPointer and glDrawArrays to draw your image.

You can use my little 2d library if you want, it gives alot of nice drawing functions, like frames of images like in blitzmax native 2d stuff, a fast image text system, and some other stuff that makes life easyer with 2d,bmx and leadwerks.

PM me if you want it

 

 

edit:ooops that thread is very old...

 

Thanks... I sent you a message.

 

Eric

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...