GR_IMAGE.DEF 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. DEFINITION MODULE GR_Image;
  2. (*
  3. ** Author : Kevin Baker
  4. **
  5. ** Version:
  6. ** 1.0 8 Aug 92
  7. **
  8. ** Function:
  9. ** Save and Restore Image files
  10. *)
  11. FROM UxFiles IMPORT File;
  12. (* ===================== constant definitions ======================= *)
  13. CONST
  14. (* ================== Image File Parameterss =================== *)
  15. PCX = 0; (* PCX ZSoft file format *)
  16. GIF = 3; (* not currently supported *)
  17. TIFF = 4; (* not currently supported *)
  18. (* ======================== Type definitione ======================= *)
  19. TYPE
  20. FileFormat = [PCX .. TIFF];
  21. ErrorType = ( OK, NotPCXFile, CoordinatesOutOfBounds, MemoryExhausted,
  22. CorruptFile, IncompatibleVideoModes, UnsupportedFormat);
  23. (*
  24. ** ErrorType is used to query the result of a call to GR_Image
  25. ** ImageRead or ImageWrite.
  26. **
  27. ** ErrorType indicates whether or not a error occured during processing
  28. ** of the Image file
  29. **
  30. ** OK - No problems
  31. ** NotPCXFile - File is not a PCX file (Read only)
  32. ** CoordinatesOutOfBounds - col,row were out of bounds
  33. ** MemoryExhausted - unable to allocate internal storage
  34. ** CorruptFile - file was corrupt
  35. ** IncompatiblaVideoModes - Image file was written in a display
  36. ** mode incompatible with the current
  37. ** video mode
  38. *)
  39. ModeType = ( monoMode, cgaMode, egaMode, vgaMode, trueColourMode,
  40. unknownMode );
  41. (*
  42. **
  43. ** ModeType used in determining the mode an Image file was written in
  44. **
  45. ** monoMode - Hercules of CGA_Mode_6
  46. ** cgaMode - CGA_Mode_4, CGA_Mode_5
  47. ** egaMode - all 16 colour modes (4 planes, 1 bit/pixel)
  48. ** vgaMode - all 256 colour modes
  49. ** trueColourMode - 24 bit colour (3 planes, 8 bits/pixel)
  50. ** unknownMode - mode was undetermined
  51. *)
  52. (*
  53. ** Image record used for general Image file information
  54. *)
  55. Image = RECORD
  56. Xpixels,
  57. Ypixels : CARDINAL; (* Image dimensions in pixels *)
  58. Mode : ModeType; (* Video Mode image was created in *)
  59. Size : CARDINAL; (* Size of decoded Image in Bytes *)
  60. END;
  61. (* ======================= File functions =========================== *)
  62. PROCEDURE ImageRead( col1, row1, (* target location *)
  63. cOfs, rOfs : INTEGER; (* start point in file *)
  64. cols, rows : CARDINAL; (* image area to read *)
  65. format : FileFormat;
  66. VAR file : File
  67. );
  68. (*
  69. ** (0,0)
  70. ** ------------------------ Image file -> --------------------------
  71. ** | | | |
  72. ** | col1,row1 | <-- Video screen | |
  73. ** | ........... | | cOfs,rOfs |
  74. ** | : : | | ..............^ |
  75. ** | : : <--------- area Image | : : |
  76. ** | : : | is to be | : : |
  77. ** | : rows | restored to | : : |
  78. ** | : : | | : : |
  79. ** | : : | | : rows |
  80. ** | : : | portion of ------> : : |
  81. ** | : : | image to be | : : |
  82. ** | <- cols ->V | restored | : : |
  83. ** | | | <--- cols --->v |
  84. ** | | | |
  85. ** ------------------------ --------------------------
  86. ** ^
  87. ** |
  88. ** (VideoConfig.xPixel-1,VideoConfig.yPixel-1)
  89. **
  90. ** Restores to area delimited by col1, row1 col1 + cols,row1 + rows the
  91. ** portion of image file delimited by cOfs,rOfs cOfs + cols,rOfs + rows.
  92. ** All coodinates are clipped to screen and file image boundaries.
  93. *)
  94. PROCEDURE ImageNDCRead( x1, y1 : REAL;
  95. xOfs, yOfs : REAL;
  96. xFrac, yFrac : REAL;
  97. format : FileFormat;
  98. VAR file : File
  99. );
  100. (*
  101. ** As for ImageRead but in Normalized Device Coordinates
  102. *)
  103. PROCEDURE ImageWrite( col1, row1,
  104. col2, row2 : INTEGER;
  105. format : FileFormat;
  106. VAR file : File
  107. );
  108. (*
  109. ** 0,0
  110. ** ------------------------
  111. ** | |
  112. ** | col1,row1 | <-- Video screen
  113. ** | ........... |
  114. ** | : : |
  115. ** | : : <--------- Image area to be written
  116. ** | : : |
  117. ** | :.........: |
  118. ** | col2,row2
  119. ** | |
  120. ** ------------------------
  121. ** VideoConfig.xPixel-1,VideoConfig.yPixel-1
  122. **
  123. ** Takes the image are specified by coordinates col1,row1 col2,row2 and
  124. ** saves it to file. Specify a file format to be read.
  125. *)
  126. PROCEDURE ImageNDCWrite( x1, y1,
  127. x2, y2 : REAL;
  128. format : FileFormat;
  129. VAR file : File
  130. );
  131. (*
  132. ** As for ImageWriter but in Normalized Device Coordinates
  133. *)
  134. PROCEDURE ImageInfo( format : FileFormat;
  135. VAR image : Image;
  136. file : File) : BOOLEAN;
  137. (*
  138. ** Obtain Image details from file. Returns true if successfully
  139. ** retrieved details. If false use ErrorQuery to determine nature of error
  140. *)
  141. PROCEDURE ErrorQuery() : ErrorType;
  142. (*
  143. ** Query the result of the most recently called Image function.
  144. ** Returns a value of TYPE ErrorType
  145. *)
  146. END GR_Image.