Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.8 KiB

  1. //
  2. // LoadImage.c
  3. //
  4. // routines to load and decomress a graphics file using a MS Office
  5. // graphic import filter.
  6. //
  7. // writen for Plus! 05/24/95
  8. // ToddLa
  9. //
  10. // Copyright (c) 1995-1998 Microsoft Corporation. All rights reserved.
  11. #ifdef __cplusplus
  12. extern "C" { /* Assume C declarations for C++ */
  13. #endif /* __cplusplus */
  14. typedef struct
  15. {
  16. LPBITMAPINFOHEADER pBitmapInfoHeader;
  17. HMETAFILE hMetaFile;
  18. } BITMAP_AND_METAFILE_COMBO;
  19. // LoadImageFromFile(LPCTSTR szFileName, int width, int height, int bpp, int dither);
  20. //
  21. // load a graphic file decompess it (iff needed) and return a DIBSection
  22. //
  23. // szFileName - the file name, can be a windows bitmap
  24. // or any format supported by a installed
  25. // graphic import filter.
  26. //
  27. // width, height - requested width,height in pixels
  28. // pass zero for no stretching
  29. //
  30. // bpp - requested bit depth
  31. //
  32. // 0 use the bit depth of the image
  33. // -1 use best bit depth for current display
  34. // 8 use 8bpp
  35. // 16 use 16bpp 555
  36. // 24 use 24bpp
  37. // 32 use 32bpp
  38. // 555 use 16bpp 555
  39. // 565 use 16bpp 565
  40. //
  41. // if the requested bit depth is 8bpp a palette
  42. // will be used in this order.
  43. //
  44. // if the image file is <= 8bpp its
  45. // color table will be used.
  46. //
  47. // if a file of the same name, with
  48. // a .pal extension exists this will be
  49. // used as the palette.
  50. //
  51. // otherwise the halftone palette will be used.
  52. //
  53. // dither 0 = none.
  54. // 1 = dither to custon palette.
  55. // 2 = dither to standard palette.
  56. // 3 = halftone to standard palette.
  57. //
  58. // returns
  59. //
  60. // DIBSection bitmap handle
  61. //
  62. #define DITHER_NONE 0
  63. #define DITHER_CUSTOM 1
  64. #define DITHER_STANDARD 2
  65. #define DITHER_HALFTONE 3
  66. #define DITHER_CUSTOM_HYBRID 4
  67. #define DITHER_STANDARD_HYBRID 5
  68. HBITMAP LoadImageFromFile(LPCTSTR szFileName, BITMAP_AND_METAFILE_COMBO * pbam, int width, int height, int bpp, int dither);
  69. // LoadDIBFromFile
  70. //
  71. // load a image file using a image import filter.
  72. HRESULT LoadDIBFromFile(IN LPCTSTR szFileName, IN BITMAP_AND_METAFILE_COMBO * pBitmapAndMetaFile);
  73. void FreeDIB(BITMAP_AND_METAFILE_COMBO bam);
  74. //
  75. // LoadPaletteFromFile
  76. //
  77. // load a MS .PAL file. as a array of RGBQUADs
  78. //
  79. // if the palette file is invalid or does not
  80. // exists the halftone colors are returned.
  81. // if hdcNearest is not NULL the colors are adjusted w/GetNearestColor
  82. //
  83. DWORD LoadPaletteFromFile(LPCTSTR szFile, LPDWORD rgb, HDC hdcNearest);
  84. //
  85. // GetFilterInfo
  86. //
  87. BOOL GetFilterInfo(int i, LPTSTR szName, UINT cbName, LPTSTR szExt, UINT cbExt, LPTSTR szHandler, UINT cbHandler);
  88. //
  89. // SaveImageToFile
  90. //
  91. // save a DIBSection to a .BMP file.
  92. //
  93. // if szTitle is !=NULL it will be written to the end of the
  94. // bitmap so GetImageTitle() can read it.
  95. //
  96. BOOL SaveImageToFile(HBITMAP hbm, LPCTSTR szFile, LPCTSTR szTitle);
  97. //
  98. // GetImageTitle
  99. //
  100. // retrives the title writen to a bitmap file by SaveImageToFile
  101. //
  102. DWORD GetImageTitle(LPCTSTR szFile, LPTSTR szTitle, UINT cb);
  103. //
  104. // CacheLoadImageFromFile
  105. // CacheDeleteBitmap
  106. //
  107. HBITMAP CacheLoadImageFromFile(LPCTSTR szFileName, int width, int height, int bpp, int dither);
  108. void CacheDeleteBitmap(HBITMAP hbm);
  109. // FindExtension
  110. //
  111. // returns a pointer to the extension of a file.
  112. //
  113. LPCTSTR FindExtension(LPCTSTR pszPath);
  114. #ifdef __cplusplus
  115. }
  116. #endif /* __cplusplus */