CanvasUsage.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <?xml-stylesheet type="text/xsl" href="../Xsl/doc2html.xsl"?>
  3. <doc>
  4. <title>Using Canvas Class</title>
  5. <chapter>
  6. <title>Using Canvas Class</title>
  7. <par>
  8. Class <ref>TImagingCanvas</ref> in <ref>ImagingCanvases.pas</ref>
  9. unit allows library user to draw onto image and apply various effects.
  10. Base canvas class works for all image data formats with direct pixel access
  11. (so not for compressed formats).
  12. Because of this some operations are slower (sometimes a lot)
  13. than implementation optimized for just one data format
  14. (as it is done for example in Graphics32 library).
  15. </par>
  16. <par>
  17. Descendants optimized for specific data formats can be created.
  18. Currently there is only most basic <ref>TFastARGB32Canvas</ref> class
  19. for <icode>ifA8R8G8B8</icode> images.
  20. </par>
  21. <par>
  22. Canvas can be created for both low and high level images.
  23. Image data is only referenced by canvas.
  24. If you change image data size (like format conversion or resizing)
  25. you must update canvas by calling <icode>UpdateCanvasState</icode>
  26. method so that canvas can update its helper structures depending
  27. on size of the data (like scanline pointers).
  28. You only need to update the canvas when size of image data
  29. changes, not after setting pixels or drawing outside of the canvas
  30. (like using <ref>CopyRect</ref> function).
  31. </par>
  32. <par>
  33. Currently Canvas class has these features:
  34. </par>
  35. <blist>
  36. <li>Set pen and fill color in 32bit and FP format. Set
  37. pen width and pen/fill mode (supported only in few functions).</li>
  38. <li>Set and get pixel colors.</li>
  39. <li>Clipping against custom rectangle.</li>
  40. <li>Draw lines, framed rectangles, and ellipses.</li>
  41. <li>Fill rectangles with solid color or with blending.</li>
  42. <li>Draw part of canvas onto another canvas.</li>
  43. <li>Stretch part of canvas onto another canvas with filtering (bilinear/bicubic/nearest).</li>
  44. <li>Drawing (Draw/StretchDraw/FillRect) with blending.
  45. Several source and destination blending factors are supported
  46. (so you can get alpha blending, adding, modulate, ...).</li>
  47. <li>Linear filters (convolution) with custom kernels and some predefined.</li>
  48. <li>Nonlinear filters with custom functions and some predefined (min, max, median).</li>
  49. <li>Point filters with custom functions and some predefined (contrast, gamma, thresholding, brightness,
  50. premultiply alpha, ...).</li>
  51. </blist>
  52. <par>
  53. You can find some canvas usage code in Tips article linked bellow
  54. and in the demos. There is still a lot of functions that can be added to
  55. canvas and hopefully they will be.
  56. </par>
  57. <linklist>
  58. <title>More Canvas Info</title>
  59. <lslink url="..\Procedures\Canvas.xml">Canvas Class Tips</lslink>
  60. <lslink url="..\Demos\Pascal.xml#ibrowser">VCL Image Browser Demo</lslink>
  61. <lslink url="..\Demos\Pascal.xml#lclimager">LCL Imager Demo</lslink>
  62. </linklist>
  63. </chapter>
  64. </doc>