AutoMidHandle .htm 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <html><head><title>Command: AutoMidHandle </title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'><link rel='stylesheet' href='../css/commands.css' type='text/css'></head><body><span class='Command'>&nbsp;&nbsp;AutoMidHandle true/false&nbsp;&nbsp;</span></p><span class='header'>Definition:</span> <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>Automatically sets the image handle of loaded images to the middle of the image.</td></tr></table><span class='header'><br>Parameter Description:</span> <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>true = images load with midhandle set as default<br>
  2. false = images load with default image handles at 0,0<br></td></tr></table><p class='header'>Command Description: <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>When an image is loaded with <a href='LoadImage.htm'>LoadImage</a>, the image handle (the location within the image where the image is 'drawn from') is always defaulted to the top left corner (coordinates 0,0). This means if you draw an image that is 50x50 pixels at screen location 200,200, the image will begin to be drawn at 200,200 and extend to 250,250.<br>
  3. <br>
  4. The <a href='MidHandle.htm'>MidHandle</a> command moves the image's handle to the middle of the image. See this command for more information about the image's handle.<br>
  5. <br>
  6. This command eliminates the need for the <a href='MidHandle.htm'>MidHandle</a> command by making ALL subsequently loaded images default to having their image handles set to mid.<br>
  7. <br>
  8. Note about the term 'handle'. There are two types of 'handles' we discuss in these documents. One is the location within an image - as discussed in this command. The other is a 'file handle', a variable used to hold an image, sound, or font loaded with a command. See <a href='LoadImage.htm'>LoadImage</a> for more information about file handles.</td></tr></table><p class='header'>Example: <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>; MidHandle/ImageXHandle()/ImageYHandle()/AutoMidHandle<br>
  9. <br>
  10. ; Initiate Graphics Mode<br>
  11. Graphics 640,480,16<br>
  12. <br>
  13. ; Set up the image file handle as a global<br>
  14. Global gfxBall<br>
  15. <br>
  16. ; Load the image - you may need to change the location of the file<br>
  17. gfxBall=LoadImage ("C:\Program Files\Blitz Basic\samples\ball.bmp")<br>
  18. <br>
  19. ; Until the user presses ESC key ...<br>
  20. While Not KeyHit(1)<br>
  21. Text 0,0,"Default Image Handle for gfxBall... Press ESC ..."<br>
  22. Text 0,14,"X handle-" + ImageXHandle(gfxBall) ; Print the location of the image handle x location<br>
  23. Text 0,28,"Y handle-" + ImageYHandle(gfxBall) ; Print the location of the image handle y location<br>
  24. DrawImage gfxBall,200,200,0 ; draw the image at 200,200<br>
  25. Wend<br>
  26. <br>
  27. ; Clear the screen<br>
  28. Cls<br>
  29. <br>
  30. ; Set the ball's handle to the center of the image<br>
  31. MidHandle gfxBall<br>
  32. <br>
  33. ; Until the user presses ESC key ... show the new information<br>
  34. While Not KeyHit(1)<br>
  35. Text 0,0,"New Image Handle for gfxBall... Press ESC ..."<br>
  36. Text 0,14,"X handle-" + ImageXHandle(gfxBall)<br>
  37. Text 0,28,"Y handle-" + ImageYHandle(gfxBall)<br>
  38. DrawImage gfxBall,200,200,0<br>
  39. Wend<br>
  40. <br>
  41. ; Makes all images load up with their handles in the center of the image<br>
  42. AutoMidHandle True<br>
  43. Cls<br>
  44. <br>
  45. ; Load the image again<br>
  46. gfxBall=LoadImage ("C:\Program Files\Blitz Basic\samples\ball.bmp")<br>
  47. <br>
  48. ; Until the user presses ESC key ... show the new information<br>
  49. While Not KeyHit(1)<br>
  50. Text 0,0,"Automatic image handle of gfxBall... Press ESC ..."<br>
  51. Text 0,14,"X handle-" + ImageXHandle(gfxBall)<br>
  52. Text 0,28,"Y handle-" + ImageYHandle(gfxBall)<br>
  53. DrawImage gfxBall,200,200,0<br>
  54. Wend<br></td></tr></table><p><b><a target="_top" href="../index.htm">Index</a></b></p></body>
  55. </html>