home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 July / AMIGA_1996_7.BIN / ausgabe_7_96 / pd-programmierung / ace_prgs.lha / gfx / image2.b < prev    next >
Text File  |  1994-11-10  |  3KB  |  93 lines

  1. {*
  2. ** An example of the use of Intuition Images in ACE.
  3. ** Image data taken from "Inside Amiga Graphics", p 182-184.
  4. **
  5. ** Author: David J Benn
  6. **   Date: 6th,7th November 1994
  7. *}
  8.  
  9. STRUCT Image
  10.   SHORTINT LeftEdge
  11.   SHORTINT TopEdge
  12.   SHORTINT xWidth    '..Width is a reserved word.
  13.   SHORTINT Height
  14.   SHORTINT Depth    
  15.   ADDRESS  ImageData
  16.   BYTE        PlanePick
  17.   BYTE       PlaneOnOff
  18.   ADDRESS  NextImage    '..Pointer to next Image structure.
  19. END STRUCT
  20.  
  21. CONST NULL = 0&
  22. CONST manDataItems = 34, balloonDataItems = 44
  23.  
  24. LIBRARY "intuition.library"
  25. DECLARE FUNCTION DrawImage(rastPort&, theImage&, left&, top&) LIBRARY intuition
  26.  
  27. DECLARE STRUCT Image manImage, balloonImage
  28. ADDRESS man_image_addr, balloon_image_addr
  29.  
  30. '..manDataItems short words of CHIP RAM.
  31. man_image_addr = ALLOC(manDataItems*SIZEOF(SHORTINT),0)  
  32. IF man_image_addr = NULL THEN STOP
  33. DIM man_image_data%(manDataItems) ADDRESS man_image_addr
  34. FOR i%=0 TO manDataItems-1
  35.   READ man_image_data%(i%)
  36. NEXT
  37. {*
  38. ** 2 bitplanes worth of data (14 x 17 bits x 2 bitplanes).
  39. *}
  40. '..FIRST BIT PLANE.
  41. DATA &H0FC0,&H3FF0,&H3330,&H3330,&H3FF0,&H3FC0,&H0FC0,&H0300,&HFFFC,&HFFFC
  42. DATA &H0FC0,&H0FC0,&H3FF0,&H3CF0,&H3CF0,&HFCFC,&HFCFC
  43. '..SECOND BIT PLANE.
  44. DATA &H0000,&H0000,&H0CC0,&H0CC0,&H0000,&H0300,&H0000,&H0000,&H0000,&H0000
  45. DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
  46.  
  47. manImage->LeftEdge     = 0
  48. manImage->TopEdge     = 12
  49. manImage->xWidth     = 14
  50. manImage->Height     = manDataItems\2
  51. manImage->Depth     = 2
  52. manImage->ImageData     = @man_image_data%
  53. manImage->PlanePick     = 3
  54. manImage->PlaneOnOff     = 0
  55. manImage->NextImage    = NULL
  56.  
  57. '..balloonDataItems short words of CHIP RAM.
  58. balloon_image_addr = ALLOC(balloonDataItems*SIZEOF(SHORTINT),0)  
  59. IF balloon_image_addr = NULL THEN STOP
  60. DIM balloon_image_data%(balloonDataItems) ADDRESS balloon_image_addr
  61. FOR i%=0 TO balloonDataItems-1
  62.   READ balloon_image_data%(i%)
  63. NEXT
  64. {*
  65. ** 2 bitplanes worth of data (14 x 17 bits x 2 bitplanes).
  66. *}
  67. '..FIRST BIT PLANE.
  68. DATA &H0F80,&H3FE0,&H7FF0,&H7FF0,&HFFF8,&HFFF8,&HFFF8,&H7FF0,&H7FF0,&H3FE0,&H0F80
  69. DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
  70. '..SECOND BIT PLANE.
  71. DATA &H0F80,&H3FE0,&H7FF0,&H7FF0,&HFFF8,&HFFF8,&HFFF8,&H7FF0,&H7FF0,&H3FE0,&H0F80
  72. DATA &H0200,&H0200,&H0200,&H0200,&H0200,&H0200,&H0200,&H0200,&H0200,&H0200,&H0200
  73.  
  74. balloonImage->LeftEdge     = 8
  75. balloonImage->TopEdge     = 0
  76. balloonImage->xWidth     = 13
  77. balloonImage->Height     = balloonDataItems\2
  78. balloonImage->Depth     = 2
  79. balloonImage->ImageData = @balloon_image_data%
  80. balloonImage->PlanePick = 3
  81. balloonImage->PlaneOnOff= 0
  82. balloonImage->NextImage    = manImage
  83.  
  84. WINDOW 1,"A man and his balloon...",(0,0)-(320,200),10
  85.  
  86. DrawImage(WINDOW(8),balloonImage,140&,80&)
  87.  
  88. GADGET WAIT 0
  89.  
  90. WINDOW CLOSE 1
  91. LIBRARY CLOSE
  92. END
  93.