CLASSES.TEX
上传用户:wep9318
上传日期:2007-01-07
资源大小:893k
文件大小:10k
源码类别:

图片显示

开发平台:

Visual C++

  1. chapter{Alphabetical class reference}label{classref}
  2. setheader{{it CHAPTER thechapter}}{}{}{}{}{{it CHAPTER thechapter}}%
  3. setfooter{thepage}{}{}{}{}{thepage}%
  4. section{class{CImage}: public CObject}label{cimage}
  5. overview{CImage overview}{cimageoverview}
  6. A CImage object represents an image which can be loaded, saved or manipulated
  7. at a pixel level.
  8. membersection{CImage::CImage}
  9. func{void}{CImage}{void}
  10. Default constructor. Use helpref{ReadFile}{readfile} or helpref{Create}{create} to initialize
  11. the object.
  12. func{void}{CImage}{param{const CBitmap *}{bitmap}}
  13. Constructs a CImage object from a bitmap.
  14. func{void}{CImage}{param{const CString& }{filename=""}, param{int}{ imageType=-1}}
  15. Reads the image from a file.
  16. {it imageType} can be one of:
  17. begin{itemize}itemsep=0pt
  18. item CIMAGE_FORMAT_BMP
  19. item CIMAGE_FORMAT_GIF
  20. item CIMAGE_FORMAT_JPEG
  21. item CIMAGE_FORMAT_PNG
  22. end{itemize}
  23. func{void}{CImage}{param{const CImage *}{image}}
  24. Constructs a CImage object from another CImage object. In fact, the image data isn't copied
  25. from {it image}, but the size, depth etc. are copied.
  26. membersection{CImage::Create}label{create}
  27. func{void}{Create}{param{int}{ width}, param{int}{ height}, param{int}{ depth}, param{int}{ colortype=-1}}
  28. Creates an array of raw bits for the image with the given properties. You must first call
  29.  helpref{CreateImplementation}{createimplementation} to tell the CImage what type of image it is, or
  30. the type will default to CIMAGE_FORMAT_BMP.
  31. membersection{CImage::CreateImplementation}label{createimplementation}
  32. func{BOOL}{CreateImplementation}{param{const CString&}{ fileName}, param{int&}{ imageType}, param{int}{ depth}, param{int}{ colortype=-1}}
  33. Initializes the CImage by creating an internal object that implements loading, saving etc. This should
  34. not often need to be called by an application.
  35. membersection{CImage::Draw}label{draw}
  36. func{BOOL}{Draw}{param{CDC *}{dc}, param{int}{ dx=0}, param{int}{ dy=0}, param{int}{ dw=-1},
  37.  param{int}{ dh=-1}, param{int}{ sx=0}, param{int}{ sy=0}}
  38. Draws the image on a device context.
  39. {it dx, dy} specify the top-left corner of the destination rectangle.
  40. {it dw, dh} specify the width and height of the rectangle to be drawn.
  41. {it sx, sy} specify the top-left source position to start drawing from.
  42. membersection{CImage::GetColorType}label{getcolortype}
  43. func{int}{GetColorType}{void}
  44. Returns the colour type of the image: DIB_RGB_COLORS or DIB_PAL_COLORS.
  45. membersection{CImage::GetDepth}label{getdepth}
  46. func{int}{GetDepth}{void}
  47. Returns the colour depth of the image.
  48. membersection{CImage::GetFilename}label{getfilename}
  49. func{CString}{GetFilename}{void}
  50. Returns the current filename associated with the image.
  51. membersection{CImage::GetFileType}label{getfiletype}
  52. func{int}{GetFileType}{void}
  53. Returns the current type of the image, which can change according to what types
  54. have been loaded or saved. The return value is one of:
  55. begin{itemize}itemsep=0pt
  56. item CIMAGE_FORMAT_BMP
  57. item CIMAGE_FORMAT_GIF
  58. item CIMAGE_FORMAT_JPEG
  59. item CIMAGE_FORMAT_PNG
  60. end{itemize}
  61. membersection{CImage::GetHeight}label{getheight}
  62. func{int}{GetHeight}{void}
  63. Returns the height of the image in pixels.
  64. membersection{CImage::GetIndex}label{getindex}
  65. func{int}{GetIndex}{param{int}{ x}, param{int}{ y}}
  66. Returns the palette index for the pixel at the given position in the image.
  67. membersection{CImage::GetPalette}label{getpalette}
  68. func{CImagePalette *}{GetPalette}{void}
  69. Returns the palette associated with the image.
  70. membersection{CImage::GetRGB}label{getrgb}
  71. func{BOOL}{GetRGB}{param{int}{ x}, param{int}{ y}, param{byte *}{red}, param{byte *}{green},
  72.  param{byte *}{blue}}
  73.  
  74. Returns the RGB values of the pixel at the given position in the image.
  75. membersection{CImage::GetWidth}label{getwidth}
  76. func{int}{GetWidth}{void}
  77. Returns the width of the image in pixels.
  78. membersection{CImage::Inside}label{inside}
  79. func{BOOL}{Inside}{param{int}{ x}, param{int}{ y}}
  80. Returns TRUE if the given point is inside the image.
  81. membersection{CImage::IsOK}label{isok}
  82. func{BOOL}{IsOK}{void}
  83. Returns TRUE if the CImage is valid. At present, just checks whether the internal
  84. implementation object is valid.
  85. membersection{CImage::MakeBitmap}label{makebitmap}
  86. func{CBitmap *}{MakeBitmap}{void}
  87. Makes a new CBitmap object from the CImage object. Untested.
  88. membersection{CImage::ReadFile}label{readfile}
  89. func{BOOL}{ReadFile}{param{const CString&}{ filename=""}, param{int}{ imageType=-1}}
  90. Reads a file of the given type.
  91. {it imageType} can be one of:
  92. begin{itemize}itemsep=0pt
  93. item CIMAGE_FORMAT_BMP
  94. item CIMAGE_FORMAT_GIF
  95. item CIMAGE_FORMAT_JPEG
  96. item CIMAGE_FORMAT_PNG
  97. end{itemize}
  98. If {it imageType} is -1, the type is deduced from the file extension.
  99. membersection{CImage::SaveFile}label{savefile}
  100. func{BOOL}{SaveFile}{param{const CString&}{ filename=""}, param{int}{ imageType=-1}}
  101. Reads a file of the given type.
  102. {it imageType} can be one of:
  103. begin{itemize}itemsep=0pt
  104. item CIMAGE_FORMAT_BMP
  105. item CIMAGE_FORMAT_GIF (not implemented)
  106. item CIMAGE_FORMAT_JPEG
  107. item CIMAGE_FORMAT_PNG
  108. end{itemize}
  109. If {it imageType} is -1, the type is deduced from the file extension.
  110. membersection{CImage::SetPalette}label{setpalette}
  111. func{BOOL}{SetPalette}{param{CImagePalette *}{palette}}
  112. func{BOOL}{SetPalette}{param{int}{ n}, param{rgb_color_struct *}{rgb_struct}}
  113. func{BOOL}{SetPalette}{param{int}{ n}, param{byte *}{red}, param{byte *}{green}, param{byte *}{blue}}
  114. Sets the palette in a variety of ways.
  115. membersection{CImage::Stretch}label{stretch}
  116. func{BOOL}{Stretch}{param{CDC *}{dc}, param{int}{ dx=0}, param{int}{ dy=0}, param{int}{ dw=-1},
  117.  param{int}{ dh=-1}, param{int}{ sx=0}, param{int}{ sy=0}, param{int}{ sw=-1}, param{int}{ sh=-1}}
  118.  
  119. Draws the image on a device context, stretching the image.
  120. {it dx, dy} specify the top-left corner of the destination rectangle.
  121. {it dw, dh} specify the width and height of the rectangle to be drawn.
  122. {it sx, sy} specify the top-left source position to start drawing from.
  123. {it sh, sh} specify the width and height of the source rectangle.
  124. section{class{CImageIterator}}label{cimageiterator}
  125. overview{CImageIterator overview}{cimageiteratoroverview}
  126. Use CImageIterator to iterate through rows and bytes of an image.
  127. membersection{CImageIterator::CImageIterator}
  128. func{void}{CImageIterator}{void}
  129. Default constructor.
  130. func{void}{CImageIterator}{param{CImage *}{image}}
  131. Constructor, associating an image with the iterator object.
  132. func{void}{CImageIterator}{param{CImageImpl *}{imageImpl}}
  133. Constructor, associating an image with the iterator object.
  134. membersection{CImageIterator::operator CImage *}
  135. func{}{operator CImageImpl *}{void}
  136. Operator, `converting' the CImageIterator object to the associated
  137. CImageImpl object.
  138. membersection{CImageIterator::GetByte}
  139. func{byte}{GetByte}{void}
  140. Returns the byte at the current position.
  141. membersection{CImageIterator::GetRow}
  142. func{void}{GetRow}{param{byte *}{buf}, param{int}{ n}}
  143. Copies the first {it n} bytes from the current row to {bf buf}.
  144. func{ImagePointerType}{GetRow}{void}
  145. Returns a pointer to the current row.
  146. membersection{CImageIterator::GetSteps}
  147. func{void}{GetSteps}{param{int *}{x}, param{int *}{y}}
  148. Returns the steps for incrementing/decrementing with NextStep/PrevStep.
  149. membersection{CImageIterator::ItOK}
  150. func{BOOL}{ItOK}{void}
  151. Returns TRUE if the current iterator position is within the image.
  152. membersection{CImageIterator::NextByte}
  153. func{BOOL}{NextByte}{void}
  154. Increments the current position by a byte.
  155. membersection{CImageIterator::NextRow}
  156. func{BOOL}{NextRow}{void}
  157. Increments the current iterator position by a row.
  158. membersection{CImageIterator::NextStep}
  159. func{BOOL}{NextStep}{void}
  160. Increments the current position by the step previously set by helpref{SetSteps}{setsteps}.
  161. membersection{CImageIterator::PrevByte}
  162. func{BOOL}{PrevByte}{void}
  163. Decrements the current position by a byte.
  164. membersection{CImageIterator::PrevRow}
  165. func{BOOL}{PreviousRow}{void}
  166. Decrements the current iterator position by a row.
  167. membersection{CImageIterator::PrevStep}
  168. func{BOOL}{PrevStep}{void}
  169. Decrements the current position by the step previously set by helpref{SetSteps}{setsteps}.
  170. membersection{CImageIterator::Reset}
  171. func{BOOL}{Reset}{void}
  172. Resets the iterator position to 0, 0.
  173. membersection{CImageIterator::SetByte}
  174. func{void}{SetByte}{param{byte}{ b}}
  175. Sets the byte at the current position.
  176. membersection{CImageIterator::SetRow}
  177. func{void}{SetRow}{param{byte *}{buf}, param{int}{ n}}
  178. Copies the first {it n} bytes from {bf buf} to the current row. If {it n} is less than zero,
  179. it is set to the width of the image.
  180. membersection{CImageIterator::SetSteps}label{setsteps}
  181. func{void}{SetSteps}{param{int}{ x}, param{int}{ y}}
  182. Set the steps for incrementing/decrementing with NextStep/PrevStep.
  183. membersection{CImageIterator::SetY}
  184. func{void}{SetY}{param{int}{ y}}
  185. Sets the y position (row).
  186. membersection{CImageIterator::Upset}
  187. func{BOOL}{Upset}{void}
  188. Resets the iterator position to the first pixel of the last image row.
  189. chapter{Topic overviews}label{topics}
  190. setheader{{it CHAPTER thechapter}}{}{}{}{}{{it CHAPTER thechapter}}%
  191. setfooter{thepage}{}{}{}{}{thepage}%
  192. section{CImage overview}label{cimageoverview}
  193. Classes: helpref{CImage}{cimage}, helpref{CImageIterator}{cimageiterator}
  194. This overview to be written.
  195. section{CImageIterator overview}label{cimageiteratoroverview}
  196. Classes: helpref{CImageIterator}{cimageiterator}
  197. This class is used for iterating over bytes in an image. For examples of use, see
  198. the CImage source code, e.g. {tt imajpg.cpp}.