High.xml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <?xml-stylesheet type="text/xsl" href="../../Xsl/doc2html.xsl"?>
  3. <doc>
  4. <title>How To ... (High Level)</title>
  5. <chapter>
  6. <title>How To ... (High Level)</title>
  7. <par>High Level interface in the current version is made of
  8. the base class <ref>TBaseImage</ref> and its two descendants
  9. <ref>TSingleImage</ref> and <ref>TMultiImage</ref>.
  10. More information on the current state of high level interface
  11. can be found in
  12. <link url="../Usage/HighLevel.xml">Usage/High Level Interface</link>
  13. section.</par>
  14. <par>You can learn how to use high level interface from the
  15. following code fragments or (more useful) high level
  16. <link url="../Demos/Pascal.xml">Pascal Demos</link>.</par>
  17. <code>
  18. // high level interface test
  19. <b>uses</b>
  20. ImagingTypes,
  21. // high level classes are declared in this unit
  22. ImagingClasses;
  23. <b>var</b>
  24. // this is one level image container
  25. SImg: <ref>TSingleImage</ref>;
  26. // this is multi level image container
  27. MImg: <ref>TMultiImage</ref>;
  28. <b>begin</b>
  29. // new 400x300x24 image is created
  30. SImg := <ref>TSingleImage</ref>.CreateFromParams(400, 300, ifR8G8B8);
  31. // resize image
  32. SImg.Resize(512, 384, rfBicubic);
  33. // you can find out whether image is valid or not this way:
  34. <b>if</b> SImg.Valid <b>then</b>
  35. WriteLn('Image is valid!');
  36. // you are free to use low level functions on high level classes
  37. // you can use ImageData property to get access to underlying structure
  38. SwapChannels(SImg.ImageDataPointer^, ChannelRed, ChannelGreen);
  39. // image can be converted to another format by simply setting Format property
  40. SImg.Format := ifIndex8;
  41. // extended format info is accessible trough FormatInfo property
  42. WriteLn('Image has ', SImg.FormatInfo.PaletteEntries, ' palette entries');
  43. // new multi image without parameters is created (default sized 1 level image
  44. // will be created)
  45. MImg := <ref>TMultiImage</ref>.Create;
  46. // single image is assigned to multi image - multi image will now have
  47. // one level identical to source single image
  48. MImg.Assign(SImg);
  49. // single image is resized
  50. SImg.Width := SImg.Width * 2;
  51. // new level is added to multi image (SImg is cloned)
  52. MImg.AddLevel(SImg);
  53. // single image is converted
  54. SImg.Format := ifR32F;
  55. // new level is inserted to multi image at index 0 (SImg is cloned)
  56. MImg.InsertLevel(0, SImg);
  57. // all levels of multi image are written to stream
  58. MImg.SaveMultiToStream('tga', SomeStream);
  59. // images are freed
  60. SImg.Free;
  61. MImg.Free;
  62. <b>end.</b>
  63. </code>
  64. </chapter>
  65. </doc>