home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / LaVolpe_Im2084129202007.psc / c32bppDIB.cls < prev   
Text File  |  2007-09-19  |  80KB  |  1,367 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "c32bppDIB"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15.  
  16. ' Credits/Acknowledgements - Thanx goes to:
  17. '   Paul Caton for his class on calling non VB-Friendly DLLs that use _cdecl calling convention
  18. '       Used when calling non VB-friendly zLIB dll versions
  19. '   Alfred Koppold for his PNG, VB-only, decompression routines.
  20. '       Used when zLib & GDI+ not available
  21. '   Carles P.V for his pvResize logic
  22. '       Used when manually scaling images with NearestNeighbor or BiLinear interpolation
  23. '   www.zlib.net for their free zLIB.dll, the standard DLL for compressing/decompressing PNGs
  24. '       Without it, we'd be limited to GDI+ for creating PNGs
  25. '   coders like you that provide constructive criticism to make this class better & more all-inclusive
  26. '       Without your comments, this project probably would have died several versions/updates ago
  27. ' For most current updates/enhancements visit the following:
  28. '   Visit http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=67466&lngWId=1
  29. ' To see a usercontrol applying a version of this class
  30. '   Visit http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=68262&lngWId=1
  31.  
  32. ' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  33. '                                    O V E R V I E W
  34. ' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  35. ' AlphaBlend API :: (msimg32.dll) , GDI+ API (gdiplus.dll)
  36.  
  37. ' About 32bpp pre-multiplied RGB (pARGB) bitmaps, if you are not aware.
  38. '   - These are used specifically for the AlphaBlend API & are GDI+ compatible
  39. '   Advantages:
  40. '       - Images can be per-pixel alpha blended
  41. '       - Opacity can be simultaneously adjusted during rendering
  42. '       - AlphaBlend does both BitBlt & StretchBlt for pARGB images.
  43. '       - Speed: AlphaBlend & GDI+ are pretty quick APIs vs manual blending
  44. '   Disadvantages:
  45. '       - The original RGB values are permanently destroyed during pre-multiplying
  46. '           -- Premultiplied formula: preMultipliedRed=(OriginalRed * Alpha) \ 255
  47. '           -- There is no way to convert pARGB back to non-premultiplied RGB values
  48. '              The formula would be: reconstructedRed=(preMultipliedRed * 255) \ Alpha.
  49. '               but because of integer division when pre-multiplying, the result is very
  50. '               close and if this should be premultiplied again & converted again, the
  51. '               calculated colors can eventually be completely different than the original.
  52. '               Fully opaque pixels & fully transparent pixels are not affected.
  53. '           ** Note: When images are converted to PNG formats, removal of
  54. '              premultiplication is performed to meet PNG specs.
  55. '       - Displaying a pre-multiplied bitmap without AlphaBlend/GDI+ will not result in
  56. '           the image being displayed as expected.
  57. '       - Not ideal for saving due to its size: SizeOf= W x H x 4
  58. '           -- better to save source image instead or compress the DIB bytes using favorite compression utility
  59. '           -- with GDI+ or zLib, image can be converted to PNG for storage
  60. '       - AlphaBlend API is not included/compatible with Win95, NT4 and lower
  61. '       - AlphaBlend on Win9x systems can be buggy, especially when rendering to DIBs vs DDBs
  62. ' Note that GDI+ is standard on WinXP+, and can be used on Win98,ME,2K, & on NT4 if SP6 is installed
  63. ' Download GDI+ from:
  64. ' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlus.asp
  65. ' Download ZLib from: http://www.zlib.net
  66.  
  67. ' ----------------------------------------------
  68. ' About Win95, Win98, NT3.5, NT4 & WinME support
  69. ' ----------------------------------------------
  70. ' These routines may not honor AlphaBlend if it exists on those systems. Win98's version,
  71. ' for example, has several bugs that can crash the application when AlphaBlending to DIBs.
  72. ' NT4, NT3.5 & Win95 do not come with AlphaBlend and I do not have WinME to test with.
  73. ' Therefore, to support these older systems, the Render routine will alphablend manually
  74. ' regardless if the AlhpaBlend API exists on the older system or not. However, this can
  75. ' be overridden by you. See isAlphaBlendFriendly routine. Therefore, AlphaBlend is only
  76. ' reliable on Win2K and above. XP & above already have GDI+
  77.  
  78.  
  79. ' Class Purpose:
  80. ' ----------------------------------------------
  81. ' This class holds the 32bpp image. It also marshals any new image thru
  82. ' the battery of parsers to determine best method for converting the image
  83. ' to a 32bpp alpha-compatible image. It handles rendering, rotating, scaling,
  84. ' mirroring of DIBs using manual processes, AlphaBlend, and/or GDI+.
  85.  
  86. ' The parser order is very important for fastest/best results...
  87. ' cPNGparser :: will convert PNG, all bit depths; aborts quickly if not PNG
  88. ' cGIFparser :: will convert non-transparent/transparent GIFs; aborts quickly
  89. ' cICOpraser :: will convert XP-Alpha, paletted, true color, & Vista PNG icons
  90. '               -- can also convert most non-animated cursors
  91. ' cBMPparser :: will convert bitmaps, wmf/emf & jpgs
  92.  
  93. ' As a last resort, when GDI+ exists, anything unable to be processed by the
  94. ' parsers (i.e., TIFFs) are sent to GDI+. If GDI+ can process the image, then
  95. ' the image will be converted, internally, to PNG to enable additional processing.
  96.  
  97. ' The parsers are efficient. Most image formats have a magic number that give
  98. '   a hint to what type of image the file/stream is. However, checks need to
  99. '   be employed because non-image files could feasibly have those same magic
  100. '   numbers. If the image is determined not to be one the parser is designed
  101. '   to handle, the parser rejects it and the next parser takes over.  The
  102. '   icon parser is slightly different because PNG files can be included into
  103. '   a Vista ico file. When this occurs, the icon parser will pass off the
  104. '   PNG format to the PNG parser automatically.
  105. ' And last but not least, the parsers have no advanced knowledge of the image
  106. ' format; as far as they are concerned, anything passed is just a byte array
  107.  
  108. ' Class Organization:
  109. ' ----------------------------------------------
  110. ' Search the class for the words NEW SECTION
  111. ' The class routines are organized in the following sections:
  112. '   Class Initialization & Termination Routines
  113. '   Public Properties & Methods (almost 60 and growing)
  114. '       Public Read-Only Properties
  115. '       Public Methods
  116. '       Class to Class Communication Methods
  117. '   Local Support Functions
  118. ' ----------------------------------------------
  119.  
  120. ' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  121. '                                       CHANGE HISTORY
  122. ' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  123. ' Accompanying FAQ.rtf is updated with every change
  124. ' Last changed: 29 Aug 07. See change history within the FAQ file
  125. ' 26 Dec 06: First version
  126. ' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  127.  
  128. ' No APIs are declared public. This is to prevent possibly, differently
  129. ' declared APIs, or different versions of the same API, from conflciting
  130. ' with any APIs you declared in your project. Same rule for UDTs.
  131. ' Note: I did take liberties, changing parameter types, in several APIs throughout
  132.  
  133. ' Used to determine operating system
  134. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As Any) As Long
  135. Private Type OSVERSIONINFOEX
  136.    dwOSVersionInfoSize As Long
  137.    dwMajorVersion As Long
  138.    dwMinorVersion As Long
  139.    dwBuildNumber As Long
  140.    dwPlatformId As Long
  141.    szCSDVersion As String * 128 ' up to here is OSVERSIONINFO vs EX
  142.    wServicePackMajor As Integer ' 8 bytes larger than OSVERSIONINFO
  143.    wServicePackMinor As Integer
  144.    wSuiteMask As Integer
  145.    wProductType As Byte
  146.    wReserved As Byte
  147. End Type
  148.  
  149. ' APIs used to manage the 32bpp DIB
  150. Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
  151. Private Declare Sub FillMemory Lib "kernel32.dll" Alias "RtlFillMemory" (ByRef Destination As Any, ByVal Length As Long, ByVal Fill As Byte)
  152. Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hDC As Long) As Long
  153. Private Declare Function GetDC Lib "user32.dll" (ByVal hwnd As Long) As Long
  154. Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As Long, ByVal hDC As Long) As Long
  155. Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hDC As Long) As Long
  156. Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hDC As Long, ByVal hObject As Long) As Long
  157. Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
  158. Private Declare Function CreateDIBSection Lib "gdi32.dll" (ByVal hDC As Long, ByRef pBitmapInfo As Any, ByVal un As Long, ByRef Pointer As Long, ByVal Handle As Long, ByVal dw As Long) As Long
  159. Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdcDest As Long, ByVal nXOriginDest As Long, ByVal nYOriginDest As Long, ByVal nWidthDest As Long, ByVal nHeightDest As Long, ByVal hdcSrc As Long, ByVal nXOriginSrc As Long, ByVal nYOriginSrc As Long, ByVal nWidthSrc As Long, ByVal nHeightSrc As Long, ByVal lBlendFunction As Long) As Long
  160. Private Declare Function SetStretchBltMode Lib "gdi32.dll" (ByVal hDC As Long, ByVal nStretchMode As Long) As Long
  161. Private Declare Function GetObjectType Lib "gdi32.dll" (ByVal hgdiobj As Long) As Long
  162. Private Declare Function GetCurrentObject Lib "gdi32.dll" (ByVal hDC As Long, ByVal uObjectType As Long) As Long
  163. Private Declare Function GetIconInfo Lib "user32.dll" (ByVal hIcon As Long, ByRef piconinfo As ICONINFO) As Long
  164. Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  165. Private Declare Function SetDIBitsToDevice Lib "gdi32.dll" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal dX As Long, ByVal dY As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, ByRef Bits As Any, ByRef BitsInfo As BITMAPINFO, ByVal wUsage As Long) As Long
  166. Private Declare Function GetDIBits Lib "gdi32.dll" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, ByRef lpBits As Any, ByRef lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
  167. Private Declare Function OffsetRgn Lib "gdi32.dll" (ByVal hRgn As Long, ByVal X As Long, ByVal Y As Long) As Long
  168. Private Const STRETCH_HALFTONE As Long = &H4&
  169. Private Const OBJ_BITMAP As Long = &H7&
  170. Private Const OBJ_METAFILE As Long = &H9&
  171. Private Const OBJ_ENHMETAFILE As Long = &HD&
  172.  
  173. ' APIs used to create files
  174. Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, lpOverlapped As Any) As Long
  175. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  176. Private Declare Function GetFileSize Lib "kernel32.dll" (ByVal hFile As Long, ByRef lpFileSizeHigh As Long) As Long
  177. Private Declare Function ReadFile Lib "kernel32.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long, ByRef lpOverlapped As Any) As Long
  178. Private Declare Function SetFilePointer Lib "kernel32.dll" (ByVal hFile As Long, ByVal lDistanceToMove As Long, ByRef lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
  179. Private Const INVALID_HANDLE_VALUE = -1&
  180.  
  181. ' ////////////////////////////////////////////////////////////////
  182. ' Unicode-capable Drag and Drop of file names with wide characters
  183. ' ////////////////////////////////////////////////////////////////
  184. Private Declare Function DispCallFunc Lib "oleaut32" (ByVal pvInstance As Long, _
  185.     ByVal offsetinVft As Long, ByVal CallConv As Long, ByVal retTYP As VbVarType, _
  186.     ByVal paCNT As Long, ByRef paTypes As Integer, _
  187.     ByRef paValues As Long, ByRef retVAR As Variant) As Long
  188. Private Declare Function lstrlenW Lib "kernel32.dll" (lpString As Any) As Long
  189. Private Declare Function GlobalFree Lib "kernel32.dll" (ByVal hMem As Long) As Long
  190.  
  191. ' ////////////////////////////////////////////////////////////////
  192. ' Unicode-capable Pasting of file names with wide characters
  193. ' ////////////////////////////////////////////////////////////////
  194. Private Declare Function DragQueryFile Lib "shell32.dll" Alias "DragQueryFileA" (ByVal hDrop As Long, ByVal UINT As Long, ByVal lpStr As String, ByVal ch As Long) As Long
  195. Private Declare Function OpenClipboard Lib "user32.dll" (ByVal hwnd As Long) As Long
  196. Private Declare Function GetClipboardData Lib "user32.dll" (ByVal wFormat As Long) As Long
  197. Private Declare Function CloseClipboard Lib "user32.dll" () As Long
  198. ' ////////////////////////////////////////////////////////////////
  199. Private Type FORMATETC
  200.     cfFormat As Long
  201.     pDVTARGETDEVICE As Long
  202.     dwAspect As Long
  203.     lIndex As Long
  204.     TYMED As Long
  205. End Type
  206. Private Type DROPFILES
  207.     pFiles As Long
  208.     ptX As Long
  209.     ptY As Long
  210.     fNC As Long
  211.     fWide As Long
  212. End Type
  213. Private Type STGMEDIUM
  214.     TYMED As Long
  215.     Data As Long
  216.     pUnkForRelease As IUnknown
  217. End Type
  218.  
  219.  
  220. ' used to create the checkerboard pattern on demand
  221. Private Declare Function FillRect Lib "user32.dll" (ByVal hDC As Long, ByRef lpRect As RECT, ByVal hBrush As Long) As Long
  222. Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
  223. Private Declare Function OffsetRect Lib "user32.dll" (ByRef lpRect As RECT, ByVal X As Long, ByVal Y As Long) As Long
  224. Private Type RECT
  225.     Left As Long
  226.     Top As Long
  227.     Right As Long
  228.     Bottom As Long
  229. End Type
  230.  
  231. ' used when saving an image or part of the image
  232. Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Ptr() As Any) As Long
  233. Private Type SafeArrayBound
  234.     cElements As Long
  235.     lLbound As Long
  236. End Type
  237. Private Type SafeArray
  238.     cDims As Integer
  239.     fFeatures As Integer
  240.     cbElements As Long
  241.     cLocks As Long
  242.     pvData As Long
  243.     rgSABound(0 To 1) As SafeArrayBound ' reusable UDT for 1 & 2 dim arrays
  244. End Type
  245.  
  246. Private Type ICONINFO
  247.     fIcon As Long
  248.     xHotspot As Long
  249.     yHotspot As Long
  250.     hbmMask As Long
  251.     hbmColor As Long
  252. End Type
  253. Private Type BITMAPINFOHEADER
  254.     biSize As Long
  255.     biWidth As Long
  256.     biHeight As Long
  257.     biPlanes As Integer
  258.     biBitCount As Integer
  259.     biCompression As Long
  260.     biSizeImage As Long
  261.     biXPelsPerMeter As Long
  262.     biYPelsPerMeter As Long
  263.     biClrUsed As Long
  264.     biClrImportant As Long
  265. End Type
  266. Private Type BITMAPINFO
  267.     bmiHeader As BITMAPINFOHEADER
  268.     bmiPalette As Long
  269. End Type
  270.  
  271. Private Const AC_SRC_OVER = &H0&
  272. Private Const AC_SRC_ALPHA = &H1&
  273.  
  274. Public Enum eImageFormat    ' source image format
  275.     imgError = -1  ' no DIB has been initialized
  276.     imgNone = 0    ' no image loaded
  277.     imgBitmap = 1  ' standard bitmap or jpg
  278.     imgIcon = 3    ' standard icon
  279.     imgWMF = 2     ' windows meta file
  280.     imgEMF = 4     ' enhanced WMF
  281.     imgCursor = 5  ' standard cursor
  282.     imgBmpARGB = 6  ' 32bpp bitmap where RGB is not pre-multiplied
  283.     imgBmpPARGB = 7 ' 32bpp bitmap where RGB is pre-multiplied
  284.     imgIconARGB = 8 ' XP-type icon; 32bpp ARGB
  285.     imgGIF = 9      ' gif; if class.Alpha=True, then transparent GIF
  286.     imgPNG = 10     ' PNG image
  287.     imgPNGicon = 11 ' PNG in icon file (Vista)
  288.     imgCursorARGB = 12 ' alpha blended cursors? do they exist yet?
  289.     imgCheckerBoard = 64 ' image is displaying own checkerboard pattern; no true image
  290. End Enum
  291.  
  292. Public Enum ePngProperties ' following are recognized "Captions" within a PNG file
  293.     txtTitle = 1           ' See cPNGwriter.SetPngProperty for more information
  294.     txtAuthor = 2
  295.     txtDescription = 4
  296.     txtCopyright = 8
  297.     txtCreationTime = 16
  298.     txtSoftware = 32
  299.     txtDisclaimer = 64
  300.     txtWarning = 128
  301.     txtSource = 256
  302.     txtComment = 512
  303.     ' special properties
  304.     txtLargeBlockText = 1024 ' this is free-form text can be of any length & contain most any characters
  305.     dateTimeModified = 2048  ' date/time of the last image modification (not the time of initial image creation)
  306.     colorDefaultBkg = 4096   ' default background color to use if PNG viewer does not do transparency
  307.     filterType = 8192        ' one of the eFilterMethods values
  308.     ClearAllProperties = -1  ' resets all PNG properties
  309. End Enum
  310.  
  311. Public Enum eTrimOptions    ' see TrimImage method
  312.     trimAll = 0             ' can be combined using OR
  313.     trimLeft = 1
  314.     trimTop = 2
  315.     trimRight = 4
  316.     trimBottom = 8
  317. End Enum
  318.  
  319. Public Enum eScaleOptions   ' See ScaleImage method
  320.     ScaleToSize = 0         ' [Default] will always scale
  321.     scaleDownAsNeeded = 1   ' will only scale down if image won't fit
  322.     ScaleStretch = 2        ' wll always stretch/distort
  323. End Enum
  324.  
  325. Public Enum eGrayScaleFormulas
  326.     gsclNTSCPAL = 0     ' R=R*.299, G=G*.587, B=B*.114 - Default
  327.     gsclCCIR709 = 1     ' R=R*.213, G=G*.715, B=B*.072
  328.     gsclSimpleAvg = 2   ' R,G, and B = (R+G+B)/3
  329.     gsclRedMask = 3     ' uses only the Red sample value: RGB = Red / 3
  330.     gsclGreenMask = 4   ' uses only the Green sample value: RGB = Green / 3
  331.     gsclBlueMask = 5    ' uses only the Blue sample value: RGB = Blue / 3
  332.     gsclRedGreenMask = 6 ' uses Red & Green sample value: RGB = (Red+Green) / 2
  333.     gsclBlueGreenMask = 7 ' uses Blue & Green sample value: RGB = (Blue+Green) / 2
  334.     gsclNone = -1
  335. End Enum
  336.  
  337. Public Enum eFilterMethods
  338.     filterDefault = 0     ' paletted PNGs will use filterNone while others will use filterPaeth
  339.     filterNone = 1        ' no byte preparation used; else preps bytes using one of the following
  340.     filterAdjLeft = 2     ' see cPNGwriter.EncodeFilter_Sub
  341.     filterAdjTop = 3      ' see cPNGwriter.EncodeFilter_Up
  342.     filterAdjAvg = 4      ' see cPNGwriter.EncodeFilter_Avg
  343.     filterPaeth = 5       ' see cPNGwriter.EncodeFilter_Paeth
  344.     filterAdaptive = 6    ' this is a best guess of the above 4 (can be different for each DIB scanline)
  345. End Enum
  346.  
  347. Public Enum eRegionStyles     ' See CreateRegion
  348.     regionBounds = 0
  349.     regionEnclosed = 1
  350.     regionShaped = 2
  351. End Enum
  352.  
  353. Public Enum eConstants      ' See SourceIconSizes
  354.     TRUE_COLOR = &HFF000000
  355.     HIGH_COLOR = &HFFFF00
  356.     TRUE_COLOR_ALPHA = &HFFFFFFFF
  357. End Enum
  358.  
  359. Private m_Tag As Variant            ' user-defined, user usage only. See TAG property
  360. Private m_PNGprops As cPNGwriter    ' used for more advanced PNG creation options
  361. Private m_StretchQuality As Boolean ' if true will use BiLinear or better interpolation
  362. Private m_Handle As Long        ' handle to 32bpp DIB
  363. Private m_Pointer As Long       ' pointer to DIB bits
  364. Private m_Height As Long        ' height of DIB
  365. Private m_Width As Long         ' width of DIB
  366. Private m_hDC As Long           ' DC if self-managing one
  367. Private m_prevObj As Long       ' object deselected from DC when needed
  368. Private m_osCAP As Long         ' See Class_Initialize
  369. Private m_Format As eImageFormat ' type of source image
  370. Private m_ManageDC As Boolean   ' does class manage its own DC
  371. Private m_AlphaImage As Boolean ' does the DIB contain alpha/transparency
  372. Private m_GDItoken As Long
  373. Private m_ImageByteCache() As Byte  ' should you want the DIB class to cache original bytes
  374. ' ^^ N/A if image is loaded by handle, stdPicture, or resource
  375.  
  376.  
  377. ' NEW SECTION *******************************************************************************
  378. '                   CLASS INITIALIZATION & TERMINATION ROUTINES
  379. ' *******************************************************************************************
  380.  
  381.  
  382. Private Sub Class_Initialize()
  383.  
  384.     ' Determine operating system for compatibility of 32bpp images
  385.     ' http://vbnet.mvps.org/code/helpers/iswinversion.htm
  386.     ' http://msdn2.microsoft.com/en-gb/library/ms724834.aspx
  387.     
  388.    Dim osType As OSVERSIONINFOEX
  389.    Const VER_PLATFORM_WIN32_WINDOWS As Long = 1
  390.  
  391.    ' Retrieve version data for OS.
  392.    osType.dwOSVersionInfoSize = Len(osType)
  393.    If GetVersionEx(osType) = 0 Then
  394.       ' The OSVERSIONINFOEX structure is only supported
  395.       ' in NT4/SP6+ and NT5.x, so we're likely running
  396.       ' on an earlier version of Windows. Revert structure
  397.       ' size to OSVERSIONINFO and try again.
  398.       osType.dwOSVersionInfoSize = Len(osType) - 8
  399.       Call GetVersionEx(osType)
  400.    End If
  401.    
  402.    ' How the m_osCAP variable works and is used througout this class
  403.    ' Value contains 1, then AlphaBlend enabled & used when needed. Not enabled on Win9x unless overridden via isAlphaBlendFriendly
  404.    ' Value contains 2, then GDI+ enabled & used when needed (set in isGDIplusEnabled)
  405.    ' Value contains 4, then zLib enabled & can be used to create/read PNGs (set in isZlibEnabled). Any O/S :: no longer used; tested as needed
  406.    ' Value contains 8, then Win98+ or Win2K+: AlphaBlend capable system else it isn't
  407.    ' Value contains 16, then a Win98 or WinME system
  408.    ' Value contains 32, then NT4 w/less than SP6 or Win95. Otherwise system is GDI+ capable else it isn't
  409.    ' Note: when m_osCap contains 17, then AlphaBlend has been overridden by user
  410.    
  411.    
  412.     If osType.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
  413.  
  414.         If osType.dwMinorVersion = 0 Then ' Win95; can't use AlphaBlend nor GDI+
  415.             m_osCAP = 32
  416.  
  417.         Else ' flag as Alphablend disabled, but capable & is Win98/ME
  418.             m_osCAP = 8 Or 16
  419.         End If
  420.  
  421.     Else
  422.  
  423.         If osType.dwMajorVersion > 4 Then ' if Win2K or better
  424.             m_osCAP = 1 Or 8    ' flag as AlphaBlend enabled (Win2K or better) and capable
  425.  
  426.         Else ' WinNT4. If SP6 or better than GDI+ capable else not. Regardless, not AlphaBlend capable
  427.             If osType.wServicePackMajor < 6 Then m_osCAP = 32
  428.         End If
  429.  
  430.     End If
  431.  
  432.     Me.isGDIplusEnabled = True  ' attempt to start GDI+, test system capability
  433.     If Me.isGDIplusEnabled Then Me.HighQualityInterpolation = True
  434.  
  435.  
  436. End Sub
  437.  
  438. Private Sub Class_Terminate()
  439.     DestroyDIB ' simply clean up
  440. End Sub
  441.  
  442. ' NEW SECTION *******************************************************************************
  443. '                           PUBLIC PROPERTIES AND METHODS
  444. ' *******************************************************************************************
  445.  
  446.  
  447. Public Property Let Alpha(isAlpha As Boolean)
  448.     m_AlphaImage = isAlpha  ' determines the flags used for AlphaBlend API
  449.     ' this flag is set by the various image parsers; setting it yourself
  450.     ' can produce less than desirable effects.
  451.     ' Used in Me.Render & Me.TrimImage, cPNGwriter.OptimizeTrueColor & cPNGwriter.PalettizeImage
  452. End Property
  453. Public Property Get Alpha() As Boolean
  454.     Alpha = m_AlphaImage
  455. End Property
  456.  
  457. Public Property Let HighQualityInterpolation(Value As Boolean)
  458.     ' When possible GDI+ will be used for stretching & rotation.
  459.     ' If GDI+ is used,then high quality equates to BiCubic interpolation
  460.     ' If not used, then BiLinear (manual processing) will be used.
  461.     ' If High Quality is false, then Nearest Neighbor (very fast, less quality) interpolation used
  462.     m_StretchQuality = Value
  463. End Property
  464. Public Property Get HighQualityInterpolation() As Boolean
  465.     HighQualityInterpolation = m_StretchQuality
  466. End Property
  467.  
  468. Public Property Get ImageType() As eImageFormat
  469.     ImageType = m_Format    ' returns image format of the source image
  470. End Property
  471. Friend Property Let ImageType(iType As eImageFormat)
  472.     m_Format = iType    ' set by the various image parsers. This is not used
  473.     ' anywhere in these classes, you can do with it what you want -- for now.
  474. End Property
  475.  
  476. Public Property Let ManageOwnDC(bManage As Boolean)
  477.     ' Determines whether or not this class will manage its own DC
  478.     ' If false, then a DC is created each time the image needs to be Rendered
  479.     Dim tDC As Long
  480.     If bManage = False Then     ' removing management of DC
  481.         If Not m_hDC = 0& Then   ' DC does exist, destroy it
  482.             ' first remove the dib, if one exists
  483.             If Not m_Handle = 0& Then SelectObject m_hDC, m_prevObj
  484.             m_prevObj = 0&
  485.         End If
  486.         DeleteDC m_hDC
  487.         m_hDC = 0&
  488.     Else                        ' allowing creation of dc
  489.         If m_hDC = 0& Then        ' create DC only if we have a dib to put in it
  490.             If Not m_Handle = 0& Then
  491.                 tDC = GetDC(0&)
  492.                 m_hDC = CreateCompatibleDC(tDC)
  493.                 ReleaseDC 0&, tDC
  494.             End If
  495.         End If
  496.     End If
  497.     m_ManageDC = bManage
  498. End Property
  499. Public Property Get ManageOwnDC() As Boolean
  500.     ManageOwnDC = m_ManageDC
  501. End Property
  502.  
  503. Public Property Get isAlphaBlendFriendly() As Boolean
  504.     isAlphaBlendFriendly = ((m_osCAP And 1) = 1)
  505.     ' WinNT4 & below and Win95 are not shipped with msimg32.dll (AlphaBlend API)
  506.     ' Win98 has bugs & would believe that WinME is buggy too but don't know for sure
  507.     ' Therefore, the Rendering in this class will not use AlphaBlend on these
  508.     ' operating systems even if the DLL exists, but will use GDI+ if available
  509.     ' Can be overridden by setting this property to True
  510. End Property
  511. Public Property Let isAlphaBlendFriendly(Enabled As Boolean)
  512.     ' This has been provided to override safety of using AlphaBlend on Win9x systems.
  513.     ' Caution. Only set this when rendering to a known device dependent bitmap (DDB)
  514.     ' Alphablend can crash when rendering DIB to DIB vs DIB to DDB. Be warned.
  515.     If Enabled = True Then
  516.         ' Overriding in play: allow AlphaBlend if system is Win98 or better
  517.         ' By default this is already set for Win2K or better
  518.         If ((m_osCAP And 8) = 8) Then m_osCAP = m_osCAP Or 1
  519.     Else
  520.         m_osCAP = m_osCAP And Not 1 ' disallow AlphaBlend
  521.     End If
  522. End Property
  523. Public Property Get isGDIplusEnabled() As Boolean
  524.     ' identifies if GDI+ is usable on the system.
  525.     ' Before this property is set, GDI+ is tested to ensure it is usable
  526.     isGDIplusEnabled = ((m_osCAP And 2) = 2)
  527. End Property
  528. Public Property Let isGDIplusEnabled(Enabled As Boolean)
  529.     ' Sets the property. If set to False by you, GDI+ will not be used
  530.     ' for any rendering, but still may be used to create PNG files if needed
  531.     
  532.     ' You can reset it to true at any time. If the system won't support
  533.     ' GDI+, then the True setting will simply be ignored -- no harm, no foul
  534.     ' To test success:  c32class.isGDIplusEnabled=True: If c32class.isGDIplusEnabled=True Then ' success
  535.     
  536.     If Not Enabled = Me.isGDIplusEnabled Then
  537.         m_osCAP = (m_osCAP And Not 2)
  538.         If Enabled Then
  539.             If (m_osCAP And 32) = 0 Then ' else Win95, NT4 SP5 or lower
  540.                 Dim cGDIp As New cGDIPlus
  541.                 If cGDIp.isGDIplusOk() = True Then m_osCAP = m_osCAP Or 2
  542.             End If
  543.         End If
  544.     End If
  545. End Property
  546.  
  547. Public Property Let gdiToken(Token As Long)
  548.     ' Everytime a GDI+ API function is called, the class calls GDI+ apis to
  549.     ' create a GDI+ token first then destroys the token after the function is called.
  550.     
  551.     ' This occurs quite often. However, you can create your own token by calling
  552.     ' GdiplusStartup and then passing the token to each class for the class to use.
  553.     ' You would call GdiplusShutdown during your main form's Terminate event to
  554.     ' release the Token.
  555.     
  556.     ' When Token is zero, the classes will revert to creating a token on demand.
  557.     ' When the Token is not zero, any other DIB class created by this class will
  558.     ' pass the token as needed. The only routine that can create a new instance and
  559.     ' returns that new instance is the CreateDropShadow method. You must set the
  560.     ' token for that class at some point for that dropshadow class to use it.
  561.     
  562.     m_GDItoken = Token
  563.     
  564. End Property
  565. Public Property Get gdiToken() As Long
  566.     ' returns the GDI+ token if one was created
  567.     gdiToken = m_GDItoken
  568. End Property
  569.  
  570. Public Property Let Tag(vValue As Variant)
  571.     If IsObject(vValue) Then
  572.         Set m_Tag = vValue
  573.     Else
  574.         m_Tag = vValue
  575.     End If
  576. End Property
  577. Public Property Set Tag(vValue As Variant)
  578.     Me.Tag = vValue ' use the object check in the Let property
  579. End Property
  580. Public Property Get Tag() As Variant
  581.     If IsObject(m_Tag) Then
  582.         Set Tag = m_Tag
  583.     Else
  584.         Tag = m_Tag
  585.     End If
  586. End Property
  587.  
  588.  
  589. ' NEW SECTION *******************************************************************************
  590. '                               PUBLIC READ-ONLY PROPERTIES
  591. ' *******************************************************************************************
  592.  
  593. Public Property Get Width() As Long
  594.     Width = m_Width     ' width of image in pixels
  595. End Property
  596. Public Property Get Height() As Long
  597.     Height = m_Height   ' height of image in pixels
  598. End Property
  599. Public Property Get BitsPointer() As Long
  600.     BitsPointer = m_Pointer ' pointer to the bits of the image
  601. End Property
  602. Public Property Get scanWidth() As Long
  603.     scanWidth = m_Width * 4&    ' number of bytes per scan line
  604. End Property
  605. Public Property Get Handle() As Long
  606.     Handle = m_Handle   ' the picture handle of the image
  607. End Property
  608. Public Property Get isZlibEnabled() As Boolean
  609.     ' Read Only
  610.     ' To create PNG files, GDI+ or zLib is required. This property informs
  611.     ' you if zLIB exists in the system's DLL path
  612.     isZlibEnabled = iparseValidateZLIB(vbNullString, 0, False, False, True)
  613.     
  614. End Property
  615.  
  616. ' NEW SECTION *******************************************************************************
  617. '                                       PUBLIC METHODS
  618. ' *******************************************************************************************
  619.  
  620. Public Function LoadPicture_File(ByVal FileName As String, _
  621.                                 Optional ByVal iconCx As Long, _
  622.                                 Optional ByVal iconCy As Long, _
  623.                                 Optional ByVal SaveFormat As Boolean, _
  624.                                 Optional ByVal iconBitDepth As Long = 32) As Boolean
  625.  
  626.     ' PURPOSE: Convert passed image file into a 32bpp image
  627.     
  628.     ' Parameters.
  629.     ' FileName :: full path of file. Validation occurs before we continue
  630.     ' iconCx :: desired width of icon if file is an icon file. Default is 32x32
  631.     ' iconCy :: desired height of icon if file is an icon file. Default is 32x32
  632.     ' SaveFormat :: if true, then the image will be cached as a byte array only
  633.     '   if the image was successfully loaded. Call GetOrginalFormat to retrieve them.
  634.     ' iconBitDepth :: the desired bit depth of an icon if the resource is an icon file
  635.     
  636.     ' Why would you want to save the bytes? If this is being used in a usercontrol,
  637.     ' saving the bytes will almost always be less size than saving the 32bit DIB.
  638.     ' Additionally, these classes have the ability to get different sizes from
  639.     ' the original source (i.e., WMF, icon, cursors) if available, but if the
  640.     ' 32bit DIB is saved, it is a constant size. The potential of different sizes
  641.     ' could allow better resizing of the image vs stretching the DIB.
  642.  
  643.     On Error Resume Next
  644.     Dim hFile As Long
  645.     
  646.     hFile = iparseGetFileHandle(FileName, True, ((m_osCAP And 24) = 8))
  647.     If hFile = INVALID_HANDLE_VALUE Then Exit Function
  648.     
  649.     If GetFileSize(hFile, 0&) > 56 Then
  650.         
  651.         ' no image file/stream can be less than 57 bytes and still be an image
  652.         Dim aDIB() As Byte  ' dummy array
  653.         LoadPicture_File = spt_LoadPictureEx(hFile, FileName, aDIB(), iconCx, iconCy, 0&, 0&, SaveFormat, iconBitDepth)
  654.     
  655.     End If
  656.     CloseHandle hFile
  657.     
  658. End Function
  659.  
  660. Public Function LoadPicture_Stream(inStream() As Byte, _
  661.                                     Optional ByVal iconCx As Long, _
  662.                                     Optional ByVal iconCy As Long, _
  663.                                     Optional ByVal streamStart As Long = 0&, _
  664.                                     Optional ByVal streamLength As Long = 0&, _
  665.                                     Optional ByVal SaveFormat As Boolean, _
  666.                                     Optional ByVal iconBitDepth As Long = 32) As Boolean
  667.     
  668.     ' PURPOSE: Convert passed array into a 32bpp image
  669.     
  670.     ' Parameters.
  671.     ' inStream:: byte stream containing the image. Validation occurs below
  672.     ' iconCx :: desired width of icon if file is an icon file. Default is 32x32
  673.     ' iconCy :: desired height of icon if file is an icon file. Default is 32x32
  674.     ' streamStart :: array position of 1st byte of the image file. Validated.
  675.     ' streamLength :: total length of the image file. Validated.
  676.     ' SaveFormat :: if true, then the image will be cached as a byte array only
  677.     '   if the image was successfully loaded. Call GetOrginalFormat to retrieve them.
  678.     ' iconBitDepth :: the desired bit depth of an icon if the resource is an icon stream
  679.     
  680.     ' Why would you want to save the bytes? If this is being used in a usercontrol,
  681.     ' saving the bytes will almost always be less size than saving the 32bit DIB.
  682.     ' Additionally, these classes have the ability to get different sizes from
  683.     ' the original source (i.e., WMF, icon, cursors) if available, but if the
  684.     ' 32bit DIB is saved, it is a constant size. The potential of different sizes
  685.     ' could allow better resizing of the image vs stretching the DIB.
  686.     
  687.     If iparseIsArrayEmpty(VarPtrArray(inStream)) = 0& Then Exit Function
  688.     If streamStart < LBound(inStream) Then streamStart = LBound(inStream)
  689.     If streamLength = 0& Then streamLength = UBound(inStream) - streamStart + 1&
  690.     If streamLength < 57 Then Exit Function
  691.     ' no image file/stream can be less than 57 bytes and still be an image
  692.     LoadPicture_Stream = spt_LoadPictureEx(0&, vbNullString, inStream, iconCx, iconCy, streamStart, streamLength, SaveFormat, iconBitDepth)
  693.  
  694. End Function
  695.  
  696. Public Function LoadPicture_Resource(ByVal ResIndex As Variant, ByVal ResSection As Variant, _
  697.                             Optional VBglobal As IUnknown, _
  698.                             Optional ByVal iconCx As Long, _
  699.                             Optional ByVal iconCy As Long, _
  700.                             Optional ByVal streamStart As Long = 0&, _
  701.                             Optional ByVal streamLength As Long = 0&, _
  702.                             Optional ByVal iconBitDepth As Long = 32) As Boolean
  703.  
  704.     ' PURPOSE: Convert passed resource into a 32bpp image
  705.     
  706.     ' Parameters.
  707.     ' ResIndex :: the resource file index (i.e., 101)
  708.     ' ResSection :: one of the VB LoadResConstants or String value of
  709.     '       your resource section, i.e., vbResBitmap, vbResIcon, "Custom", etc
  710.     ' VbGlobal :: pass as VB.GLOBAL of the project containing the resource file
  711.     '       - Allows class to be mobile; can exist in DLL or OCX
  712.     '       - if not provided, class will use resource from existing workspace
  713.     '       - For example, if this class was in a compiled OCX, then the only way
  714.     '           to use the host's resource file is passing the host's VB.Global reference
  715.     ' iconCx :: desired width of icon if file is an icon file. Default is 32x32
  716.     ' iconCy :: desired height of icon if file is an icon file. Default is 32x32
  717.     ' streamStart :: array position of 1st byte of the image file. Validated.
  718.     ' streamLength :: total length of the image file. Validated.
  719.     '   -- See LoadPicture_Stream for the validation
  720.     ' iconBitDepth :: the desired bit depth of an icon if the resource is an icon
  721.     
  722.     ' Tips:
  723.     ' 1) Store 32bpp bitmaps in the "Custom" resource always. Storing in the
  724.     '       Bitmap resource can change color depth of the image created by VB
  725.     '       depending on your screen settings
  726.     ' 2) Icons, normal bitmaps, & cursors are generally stored in their own sections
  727.     '       However, with icons containing multiple formats, VB will extract the
  728.     '       closest format to 32x32. May want to consider storing these in "Custom"
  729.     ' 3) All other types of images are normally stored in the "Custom" section
  730.  
  731.     On Error GoTo ExitRoutine
  732.     
  733.     Dim oWorkSpace As VB.Global, tPic As StdPicture
  734.     
  735.     If VBglobal Is Nothing Then
  736.         Set oWorkSpace = VB.Global
  737.     ElseIf TypeOf VBglobal Is VB.Global Then
  738.         Set oWorkSpace = VBglobal
  739.     Else
  740.         Set oWorkSpace = VB.Global
  741.     End If
  742.     
  743.     If VarType(ResSection) = vbString Then
  744.         Dim inStream() As Byte
  745.         ' could be anything, PNG,icon,gif,32bpp bitmap,wmf, etc
  746.         inStream = oWorkSpace.LoadResData(ResIndex, ResSection)
  747.         LoadPicture_Resource = LoadPicture_Stream(inStream, iconCx, iconCy, streamStart, streamLength, , iconBitDepth)
  748.     Else
  749.         ' can only be single icon, bitmap or cursor
  750.         Set tPic = oWorkSpace.LoadResPicture(ResIndex, ResSection)
  751.         LoadPicture_StdPicture tPic
  752.     End If
  753.     LoadPicture_Resource = Not (m_Handle = 0&)
  754.     
  755. ExitRoutine:
  756.     If Err Then Err.Clear
  757. End Function
  758.  
  759. Public Function LoadPicture_StdPicture(Picture As StdPicture) As Boolean
  760.  
  761.     ' PURPOSE: Convert passed stdPicture into a 32bpp image
  762.     
  763.     Me.DestroyDIB
  764.     If Not Picture Is Nothing Then
  765.         ' simply pass off to other parsers
  766.         If Picture.Type = vbPicTypeIcon Then
  767.             ' pass to icon/cursor parser
  768.             Dim cICO As New cICOparser
  769.             Call cICO.ConvertstdPicTo32bpp(Picture, Me)
  770.             Set cICO = Nothing
  771.         ElseIf Not Picture.Type = vbPicTypeNone Then
  772.             ' pass to bmp,jpg,wmf parser
  773.             ' Note: transparent GIFs should not be passed as stdPictures
  774.             '   Pass transparent GIFs by Stream or FileName
  775.             Dim cBMP As New cBMPparser
  776.             Call cBMP.ConvertstdPicTo32bpp(Picture, Me, 0&)
  777.             Set cBMP = Nothing
  778.         End If
  779.         LoadPicture_StdPicture = Not (m_Handle = 0&)
  780.     End If
  781.     
  782.  
  783. End Function
  784.  
  785. Public Function LoadPicture_ByHandle(Handle As Long) As Boolean
  786.  
  787.     ' PURPOSE: Convert passed image handle into a 32bpp image
  788.  
  789.     Dim icoInfo As ICONINFO, tPic As StdPicture
  790.     If Not Handle = 0& Then
  791.         Select Case GetObjectType(Handle)
  792.         Case OBJ_BITMAP, OBJ_METAFILE, OBJ_ENHMETAFILE
  793.             ' we should be able to convert this to a stdPicture...
  794.             Set tPic = iparseHandleToStdPicture(Handle, vbPicTypeBitmap)
  795.         Case Else
  796.             ' Test for icons & cursors
  797.             If Not GetIconInfo(Handle, icoInfo) = 0 Then
  798.                 ' got it; clean up the bitmap(s) created by GetIconInfo API
  799.                 If Not icoInfo.hbmColor = 0& Then DeleteObject icoInfo.hbmColor
  800.                 If Not icoInfo.hbmMask = 0& Then DeleteObject icoInfo.hbmMask
  801.                 ' convert to stdPicture...
  802.                 Set tPic = iparseHandleToStdPicture(Handle, vbPicTypeIcon)
  803.             End If
  804.         End Select
  805.         If Not tPic Is Nothing Then
  806.             ' send to this routine to process
  807.             LoadPicture_ByHandle = LoadPicture_StdPicture(tPic)
  808.         End If
  809.     End If
  810.     
  811. End Function
  812.  
  813. Public Function LoadPicture_ClipBoard() As Boolean
  814.     
  815.     ' PURPOSE: Convert clipboard object into a 32bpp image
  816.  
  817.     On Error Resume Next
  818.     With Clipboard
  819.         If (.GetFormat(vbCFBitmap) Or .GetFormat(vbCFDIB) Or .GetFormat(vbCFEMetafile) Or .GetFormat(vbCFMetafile)) Then
  820.             If Not Err Then LoadPicture_ClipBoard = LoadPicture_StdPicture(.GetData())
  821.         End If
  822.     End With
  823.     If Err Then Err.Clear
  824. End Function
  825.  
  826. Public Function LoadPicture_FromOrignalFormat(ion LoadPicture_FromOrignalFormat(ion LoadPicture_FromOrignalFormat(ion LoadPicture_FromOrignalFormat(ion LoadPicture_FromOrignalFormat(ion LoadPicture_FronPvbCFDIB) Or .GetFormat(vbCleource Cction
  827.  
  828. Public Functi&iLconBiFile Lib "sen Loade = LA_StdPicturSet ue Functi&iPhbmMaskse
  829. c Functi&if
  830.  
  831. Private Type ICONINFO
  832.         Set tPic = oWorg) As B          oMsly, these classes have the ability toeo.hbmMas:fapable Pbsly,/***********FI,ionCy :: der
  833.             ese G,32bpp bitmap,wmf, err Then Err.Clear
  834. End Functio0bPas:fapablgnd If
  835. conInfo API Dim ihen
  836.    E(l(rihen
  837.    E(l(ri ' PURPOSE: oaaen
  838.         SenPhbmMality toeo.hbmMas:fapAe
  839.         Sel the  passeS*d If
  840. conInfOtsen ) As Longure,
  841. Public **FI,ionCyCidBrd array 
  842.  
  843. Puity tol the  passeS*d If
  844. conInfOtsen ) As Longure,
  845. Public **FI,ionCyCidBrd array 
  846.  
  847. Puity toadPictri ' PUn if the resotol tnfOtsitRoutine
  848.     
  849. :            d.
  850.     a
  851.             Set tPic = iparseHandleToStdPictureerty Let Tag(vV         this routirty E = 1024 nen Err.Clear
  852. End Functio0bPas:faFDIB) Or .       oMslyyyyyyyyyyyyyy) As BooleanPicture
  853.     If Not HaltBeer
  854.    anything, PNG,icon,gs Long
  855. PrihDC As L yCidBrt   ' Not HaeetFormaty    th = LoadPI      pI      p      pI      p Set oWorkSpFileName,lth = Loaoo, By.= 4      '(scanFromOri1=ablgnd If
  856. conInfo API DiBooCidBrd arrst's VB.'aThen DeleteObject icoInfo.hbmColor
  857.                 If Not = 0 The////Src As Long, ByVal D VB OBJ_BIT biCo>2eIf TypeOfuf the resotol tnfihen
  858.    E(l IsObjecV///Src As Long, ByVated.tPic the BJ_META>2eIHandle, icoInfo)   ' Note GDIsng, Byle
  859.    GDILoadPic, Byle
  860.    GDILoadPic, Byle
  861.    GDILoaon
  862.  
  863. Public FdPic,  th = LoadPI      pI      p      pI     d64st always be lesrcontrol,
  864.     ' saving the bytes will almost always be less size than saving the 32bit DIB.
  865.     ' Additionally, these classes have the ability to get different sizes from
  866.     ' the original source (i.e., WMF, icon, cursors) if available, but if the
  867.     'anfo(Handle, icIsng6G ResSection)
  868.         LoadPictureca       DILoadPic, Byle
  869.       ilable, but if the
  870.  ontrol,eource Cctiobut i2bpp bitmap,wmng, _
  871. sPictureca       DILoad&)
  872.                 m_hDC = CreateOfuf th       s_ILoadPic, Byle
  873.      +(  Byl'anfo(H tol the  passeS*d If
  874. conInfOtsen ) As Longure,
  875. Public **FI,ionCyCide_ClipBColoriendtOrgg multtttttttttttttttt   ' convert to ILoaon
  876.  
  877. Pu
  878.             ' send to this routine to process
  879.       ]rmat(tttttt   ' converh = LoadPI      pI,operty
  880.     ' icon4e lesrcont icon4e lesrcont icotl1FronPvsture_ClipBrgg  p SectureBandlec As BooCctiobut i2bppicture_Frdle, icoInfo) = 0 Thene,
  881.       ]aultiple formats, VB gdiToken() As Lle formansp;s    ' send     p Set oWorkSpFiaM      pI,operty
  882.  oken() tine to procesailabR     LoadPiureBan  Load.fprocesailabR     LoadPLE,iiiiE: oaaeirouti' send     p Set aaeiroFileSizOil referencevate Typeasses have the ability to get different sizes from
  883.     ' the original source (i.e.' (e_ClipBCo'Rsend t.e., WMF, ireamSta(ttttting   , Long4st always      If (is fpBCo'RsdPLE,iiiiE:cture..dce u     SectureBitmap,wmng, _
  884. T  Riuc u Cmat of te ab ine to g, _
  885. TbjectType(Handle)
  886.         /aaultiple formats, VB gdiTok e
  887. conInfOtsen LE,i#o procobut i2bpp bitif the
  888.     p As Integerafir+e, Me)
  889.          ginalLe works and is usnd     Bhns contimc FunlipBoaormat(ion LoadPicture_FronPvbCFDIB)oadPicture_FronP&iture_FronPvbCFDtD kais fpBCo'RsdP   ' ideaecV///Src As Long, 
  890. Public oInfo)ndle,KignalFormaursors      ilable i2bpe, vbPicTypeBithFile     If (is fpBCo'RsdPLE,iiiiEepbI:Bicotl1FronPvsture_ClipBrgg  p SectureBandlec As BooCctiobut i2bppicture_Frdle, icoInfo) = 0 Thene,
  891.       ]aultiple formats, VB gdiToken() As Lle formansp;s    ' send     p Set oWorkSpFiaM      pI,operty
  892.  oken() tine to procesailabR    vV      /8mats, /////reBandlec As Booap,wmng, _
  893. T  RSerty
  894.  
  895.  
  896. ' esailabId.fprocesRee host's VB.to procesaidlec Asg  p SectureBos routine to process
  897.       ]rmat(tttvsture_Cli
  898.       ]asture_Cl multiple formats, VB will ex   O VB 'aila use GDI+ if avs:fapablgnd If
  899. conRfferent si/cti&iLconBiin98 or VB talue cont- ' streamLength , VBltiple for98 or  pI      oken() As Lle formad = 1
  900.   LA_Sr parser
  901.         
  902.             DimOmMase for98 nt si/ct
  903.     or VB talnicode-cahe original sourc   ' number of bytes **FI,ionCyCidBrtiple formatouncti&iPhb(VB talniiroperty Get1 talnested b_)
  904.       98 or VB, BylB ta1 ex   O VB 'a    ' send    IsId.fpraImage As BooleTUrsor tot_Cl multiplCl multiplCl  Optional ByVal iconsp,wmf, err Then Err.Clear
  905. PpBooap,wm  
  906. :    b        roce9  of im host's VB.to procesaidlec Asg  p SectureBos routi VB.Globa   &iture_FronPvbCFDt  Riuc u Coaormat(ion Loadtultipl Lo OIs Noth   ort
  907.     ' GDI+, thuE
  908.  
  909. re_FrCFDtPPPPPPPPPPPPPPPPPPPeo6ptional OIs Noth   ort
  910. curshe abilitrmat(ithing
  911.         End Ifnterp Or .GetFor' AdditDacMe)
  912.          m_osCAP =///////ipnd CAP hter    't of icon if file is an ic
  913. re_FalFN>B 4oth   ortnSet oWorkSpFiaM       Bhns esDat(   ' source ima    'Ytttt fe_FrCFDtPPPPhns esDat(   ' source Phns esDat( cesume NeLong, ByVeIf TypeOfuf iconsp,sCAP =eStart  Me,DDtttt fe_FrCFDtPPP'iC_A Me,DDtttt fe_F Resumeile
  914.     
  915. End Function
  916.  
  917. Public Function LoadPicture_Stream(inStream() As Byte, _
  918.                          tu
  919.     
  920. End Function
  921.  
  922. Public Function LoadPicrStre. voriginanyStre.  Or .Ge    
  923. End Functionr.sised,tCVB taltaPicture_Resource(Byiptre.  Or .Ge  IgdiTokemng, _tmap,wmng, _
  924. T ld not bNMeHandle MDtPPPPPPPPPPPPobB taltaPicture_Resoununction Lo****g, _tma source Phns esDat( cfast, less nction L  p     ecurrseHandlction Lol If thiseHand create a nenction Lobut iyaTion Lo****g,'obuon Lol If th ' saving the bytes rser
  925.       e ICOE     Seuvdlctio0the byred heighe/streamken() tinile) Or .Gar
  926.     It byteransparency
  927.  ngure,
  928. Public **FI,itine er As///////ipnd CAP hter   pI     PhDC As L yCie.sis pI,opertymy
  929.  ng        ,icon,gs Lons  passf       ile = iparseGetFileHandlebo'Rsend rocesRu can create your Stre.  Oru can c            If Not = 0 The////Src As Long, Bynd CAP hter    't of icon ifeI4/SP6+ fast, li2bppicici u Coaofnterp se.  Or .Ge sa    'Ytttt fe_FrCFDtC th    wor n d.
  930.     ase
  931.      tl1Fronf      nvert  Phns esDaton Loadtultipl Lo OIs Nmpiled OStream or Fil not be used
  932.     ' for any renderiume NeLong, ByVeIf ast, less nction L  ppppppppR&T d.
  933.  TPh) be u array into a 32ng, ByVI' for (e_Cl  End If
  934.  
  935.    MHWfe_F     (ion L  pppeighe/strealic **Io procesailabR  tPPPPhnsat, iconBitslyyyyyyb MyCie.sis pIo teIfkSpFilenalLe works e//Src As Long,eeperty
  936.   Seuis usnd   nBitkSpFilenalLe w  paesDate_ClipBrgg e NeLon
  937.  
  938. ppicture_Frdyonverts VB.GlobalToInfend rocesRu can cr=erp se.  Or .Ge sa    'Ytttt fe_FrCFDtC th    wor emenyyyyyb Thenppicture_Frdyonverts VB.Glrmat
  939.     ImageType = m_Format    ' returns image format of the source image
  940. End Properdtultsource image
  941. End Properdtultsource image
  942. Entalnicage
  943. End Properdtultsource image
  944. Entalnicage
  945. End Properdtultsource image
  946. y, these clAtroperdtI' saving the bytource imDe
  947. EntalniOSE: Co_Poinion LoadPicrStre. voriginanySt  Lorce in L  Lorce in L  Date_ClipAhLorce in L  Date_ClipParameters.
  948.     ' F.PI      pIlP\itart,Gnic
  949. curshe abicage
  950. End&B talue cod image t
  951.     oadPicture_FronPvbCFDIB)oadPicture_FronP&ituntalniinalLH s will amage creat   ' conven
  952.   Type(iT
  953.  ponP&ituntalniina F.c Properdtu)
  954.     e
  955. End Properdtituntalniina Ftsoud Pradow cl   e
  956. End P        m_Tag = vValue
  957.     End If
  958. Endicture_Frdyonverts VB.GlobalToInfe8 Tag = vValue
  959. Pubure_FromOrignalFormat(ion LoadPI   ' Addif Value
  960. Pudyonvrc AsxB(), icL yCie.Id Properdtulbuo conv    '       (Byiptre.  Or .G   't ofmu Malue
  961.     En(   '       sa) As Lle v    '       (ByiptreeTal srptional Bylbuo conv    '    rtnSetaic
  962. re.to conv    '   rocesO1,v    '    SectureBos roFronP&ituntt ' converh = LoadPI Select Ca  't SNhbor (very 3LoadPI Select Ca  't SNothing Then
  963.         ' simply pass off to other pdlebo'Rsend rocesRu  differv    '   rsaicod imav      ' operati&ituntt rat^mav   Iher pdooCctiobut isxB(), icL yCie.Id Properdtulbuo conv    '       (Byiptre.A loaded by handle, stdPicture, or resource
  964.  
  965. *************** '   rocesO1,v    ' _Handle   ' g = vValuce handletdPicmat  )
  966.    ken() As ************ 'Lons
  967.     g   roceSectu
  968.     EnnP&itulabR   dle   ' gource imDesSection)
  969.         LoadPicture_StdPicture tPic
  970.     
  971.     EnnP&iiiiiiiiiiiii
  972.      fhat can create a new instance andedFriendeDC ======Br pdooCctiobut isxB(),,aTion LpdooCctiobutpicVI' for dooCctidion L  ppppppppppppppppppppppp,,aTion LpdooCctiobutpicVI' for tolpicdtulbuo conv    '       (ByirfLA_StdPicturSeesDE_COLOR_ALP ireamSta(ttttting   , Long4st alwDate_ClipParameters.
  973.     ' F.PI      pIlP\itart,pppppp.PI    2r
  974.     It bytC  
  975.     EnnP&iiiiiiiiiiiii
  976.      fhatery 3LoadEbfpraIm    Emiiiiiiipe(Haoth   ' F.PI      pIl;t of the source ceSectu
  977.  .am,-y 3LoadEbfpraIreBan   ' stream.(),,aTionhiina Fts Long4st alwDate_ClipParameters.
  978.     ' F.PI      pIlP\itart,pppp2r
  979.     Itepth ofaP\itaigeType =nd Enum
  980.  
  981. PublicB)oadPict cBMP As New cBMPparser
  982.             Call maursors      ilable i2bpe, vbPicTypeBithFile     If (is fpBCo'RsdPLE,iiiiEepbI:Bicotl1FronPvsture_ClipBrgg  p SectureBandlec As BooCctiobut i2bppicture_Frdle, icoInfo) = 0 Thene,
  983.       ]aultiple formats, VB gdiToken() As Lle formansp;s    ' send     p Set _idion L  ppppppppppppyT&T d.n F.PI      pIlP\ir any ran crekPsae e0f0. used
  984. tn pixeltF pIl files if 'Or .G2 AlphaBlend tions   ' S 't +..0+t image handle in. usee byred h LpdooCctieBan   ' stresDaton sS  
  985. End F     OptiepppppppyT&T w7he////S   End I OBJSnndletdPi ken()l1FroeValidateZLI
  986.   bCctidp SectureBos routi VBureBos rs 
  987.     EnnPw,b\itaigeType =nd amansp;s/ VBureBosa ' wiosCAP = m_osCAP Or d.n F.PI      pIlP\ir a oWorkSpnc)eppppProperdtultsource image
  988. Entalnicagat of the fkSpFilte eI
  989.   bCcyays. Stories to Bi Stori     Optional ByVal stream' pdooCct yCidBrt n F.PI aohingFOa n d.
  990.   icTypeage ream' streamLength , VBlt   fhatL  Date_ClipParam' wiosCAP = m_osCAP Or d.n.ve the
  991.        ,ilte ert
  992. curshe abi ream' /CPublic Funcns, nr'o teIfkSpFilsItoriesPicturrt
  993. Ihe abi rTroeValidateZLI
  994.   bCc VBureBosa ' wiosCAP = m_oBitDepth ::lse
  995.  
  996.         If osTe used fture_FronP&ituntalniinalLH s will amage creat   ' conven
  997.   Type(iT
  998.  ponP&ituntalniina
  999.   Type( th ' s As Lle v    '  lOlurpe(iT
  1000.  poou canp Type( tCfierMethods
  1001.     filterDefault = 0 A1le indeiTponP&itA    or VB talnicode-c       If8lP\ir a oW>Length , Vc  LoadPicrStre. voria  Datl ivale fo   fhat can create a new instance andedFriendeDC ===le
  1002.     New       If os&ituntt rat pIlP.pe(iT
  1003.  ponP&itu   LureBand  If os&ituntt rat pIlP.yT&T d.A     If os&ituntt rat pI2lnicoded If
  1004. Type(  Vc  LoadPicrStre. vortmap) OIf
  1005. A    m..dce      ilable i2bpe, vbg        ,   ,   ,   ,   ,   ,,ld CAP hte:t&     TiseHanreate a new inst:t&     </rce iolend tions   ' S 'ats, VBVc  Lte a new &N       ,ilte ert
  1006. curshe abi rdestr
  1007. pp)
  1008. erdtu
  1009. Enta
  1010.     '       - For example, if this class was iiolend e indeeteObject iRS*d If
  1011. conInfOtsen    - ForindeeteObject iRS*d If
  1012. conInfOtsen    - ForindeeteObject iRS*d If
  1013. conInfOblbuo conv    '       (Bynd e indeeteObject iR( d If
  1014. conInfOblbuo conv    ' ure_FronP&iRw"icTypeNone Then
  1015.     iic Funcns, nr'o teIfkSpFilsItoriesPeeteOuronP&iR<iR( d IfeObjec_Tag
  1016.    PeeteOuronP&iR<iR( d sd  Iu   LurAPubliD( d Il not be us d Il not be us d Il not be us d Il not be us pis fpBCo(t iRS*dpfl not be be us d GIFCo(t iRS*dpfl not be hbor (veOus d Ing these ( d INiRS*dpfl not be hbor (ve  Iu   LurAPubliD( d Il notshFile     
  1017.     ImTv_FronP&iot m_Hge As Boolean '0 _
  1018.                             Optionalvor (ve  Iu   LunInfObliD( d Il3 andedFriendeDC ======Br pdooCctiobut isxB(),,aTion LpdooCctiobu1gdditiona
  1019. ************************oy hand  ,   ,   ,,ld CAP pnc)eppppPro2bpp ItorooCctiob(******dobu1gdditioioio******dobu1gdon file. Dtuntaln(oadPic, ByleGetObjectType(Handle)
  1020.         Case OBJ_BITMAP, OBJ_META     Otsen LElse notadPic, ByleGbTe        os. be ulP\i    esRu  differv    '   rDC ===lyeGbTe        os. be g pdooCctiobut isxB(dpfl not TiseHanreate a new inst:t&     </rce iolend tions   ' S 'ats, VBVc  Lte a new &N       ,ilte ert
  1021. curshe abi rdestr
  1022. pp)
  1023. erdtu
  1024. Enta
  1025.     '       - For example, if this class was iiolend e indeeteObject iRS*d If
  1026. conInfOtsen    - ForindeeteObject iRS*d If
  1027. co    -nd be ablR andedFriendeDC ====    p Set oW ab i    - )iiii
  1028.      fhatery 3Ef this clecEferv    '   rDC ===l BooCctiontugeType = m_For 3Ef thisionssPhbmMality s esDat.E 3Ef th1et ow      i1et ow      i1et ow      i1et ow    (iparseHandVrindeeteObjeIe the adifferv    '   rDC ===mansp;s    ' send     p Set _idion L  pp'                     aart,ppp    bFct yCidBrt n F.PI aohingFateOfuft.E 3Ef     1et ow    sniinSooCc       aart,ppp fuft.E ) - poou   aannxit Fun) - r Tisese
  1029.   ,ua source Ph       - Forrndle  - Fp,ppp f,iltx+.VB gdiToken() AseE 3Ef th1et ow      i1se
  1030.   ormats           Call othing  Ca  't SoCc       aart,ppp fuft.E ) - poou   aannxit Fun) - r Tisgource 3  ormats   ec
  1031.     EnnPw,buty ndeeteObject iRPicred ice  !FPicture_FronkDan SP6 or   - For exatuntalniinalRPicred ice  !FPicture_Fron S  1et owFor exatuntalni bCc VBureBosa  WMF,procesai bCc ject teObject iRPicred ice  !F,HesDat.E 3Ef th1ecedib, if one  be us aFunction
  1032.  
  1033. PuntalniinalRPicred ice  !FP
  1034.  
  1035.    ingFateOfuf ter
  1036.     m_For 3Ef t andedFriendeDC CO As New cICOparser3Ef t irfity s esMality s esDlHesDat.E 3EfwdIlipParamne  be u.VB gdiToken() AseE 3Ef B)BureBosa 'p esMality s esDlHesDat.E 3Efw&&iai is already set for fine te) OBJ r Tisgource 3  orisGVepth icVI' for dooCcc Funcns, nrindeBaIiparsreBosa 'p esMalitestr
  1037.  poou( d               rignalF     Call ( tCfierMethods
  1038.   FalFN>B 4r VB taln Itoroce 3  orioou   aannxit Fu1his clec
  1039.         inStream = oWorkSpace.LoadResData(ResIndex, Resfe0&, vbNuciinSooC INiRS*dpt.E ) -on Then
  1040.             ' pas/ )iiccccccccccccca***********CFDtPPPa  End IriE
  1041.    ken+ons
  1042.    Ffln Ito
  1043.          ' pas/ )iicccim, ioPrope= oWorkesai bC GDILoadPicWith
  1044.     If Err Then Err.Clear
  1045. Eon, cursors) ibim, ioPrsce i Fun) - r h
  1046.     I=(    If E,orkS ThenILoadPicWith
  1047.   e( tCfierMethong,a*****Loar the vNew a   ' .ppp fuft.E ) - poou   aan      ,a****)taic
  1048. re.to conv    '   rocesO1,v    '    SectureBos roFronP&ituntt ' converh = LoadPI Select Ca  't SNhbor (very 3LoadPI Sele h
  1049.     I=(oaded. Call GetOrginalFormatv't SNhbor (very, vbrkesai bC GDILoadPiiicccccccccciiMethods
  1050.   FalFN> is an ic(tPic rocesO1,v    '   \iiMethods
  1051.   FalFN> is an ic(tdcca*&ituntt ' csO1,v    '  an ic(tdcca*se classesiiMetp)
  1052. n, hns esDiMetp)
  1053. n, hns esDis annnnnnnnnnnnnnnnnnnndthe resotol tnfOtsitRoutine
  1054. nfOtsitRVepth ita)
  1055.    lFN> isiToken = m_GDItoken
  1056. EndcesO1,v estr
  1057.  poou( d   dPiiiccccccus d Il no    ' hbor (very, vbrksO1,v estesend t.e.,sEd Function
  1058.  
  1059. Public Fud Il no.v the vNew a   ' .ppp fuft.E ) - pYErr Then Err.Clear
  1060. End FunctionMF, 3 transparent=ee vNew a   ' .ppp fuft.E ) - pYErT8 a   ' .pccccus d Il no    ' hbor (very, vbrks**************f osTe used  vbrkesai If8l   D, vhisionss)**********f osTe 4ce
  1061.  
  1062. *************** '   rocesO1,urce section, i.e., vbResBitmap, vbResIcon, "Custom",sosCAP =ppppptlrocect yCidBrt n F.PI -(BynddBrfln Ito
  1063.       a stdPP =ppppptlr Il not be us d Il not be us d Il tttttt   b     D 3 transparent=ee vNew a   ' .ppp fuft.E, vbrks(tdcca*&ituus d Il tttttt   b     D 3 transparent=ee vNew a   ' .ppp fuft.E, vbrks(tdcca*&ituus d Il tnverh = LoadPI_Fro Errai bC GVBureBosiicccccccccckesSeleurienbe us d Il nh = Loadv
  1064.     ImageTudyonfn = m_G    ioaded.ert passed stdPicture into a Loadvre_FromY&Ca  't SNhbor (very 3LoadPI Sele h
  1065. n   ' iR(hhhhh GDILoureBosFronP&ituntt ' conveTypDI+,****nd Funcc m_Tag = vValue
  1066.  ' iR(h a Loadvre_FromY&Ca  't SNhbor (very 3LoadPI Sele h
  1067. nS.pcce_Cliourceorkesai bC m_Tag = vVCliourceorke*******A+,****nd aveForm' d Il nPeA+,***********Bttt   b     aveForm'4st C GDILoadPiiiccc     I*** .ppp f fpBCo(t iRS*dpfl nmage
  1068. End pfl nmage
  1069. EnSet _idrd array 
  1070.  
  1071. Puity toadity    LurAPubliD( d Il notshFile     
  1072.     ImTv_FronP&iot ntt ' converh = LoadPI Select Ca  't SNhbor (very 3LoadPI Select Ca  't SNothing Then
  1073.         ity toadXvPpft.E ) ----l nnnnnnnnnnnnnnn',sai bC m_Ta&, _
  1074. iendeD   EnnPw,buty ndeeteObject iRPicred ice  !FPicture_Fronk-l nnn
  1075.  
  1076. Pu= Oean, _
  1077.                ype =nd Enum
  1078.  = 8))
  1079.     If hFile = INVALID_HANDLE_VALUE Then Exet oW ab i e =nd    '    s Bool VALUxet oW a CAP. Default is 32xEbrks(tdB      Optional ByVal iconcfromis 32xEbs
  1080.    Ffln      ParamndcN   2ccccccosafety of using AlphaBlend on Win9x converh = LoadPI Select e
  1081. EnSekxSebonP&ituAlphaBlend oCctiobutpicVI'lpha3LoadPI Sele h
  1082. n   ' iR(hhhhh GDILovd Iri ilable.) OBJ_B, VALUxet oW aaNhbor (, "Custom",sosCAP =ppppptlrocect yCidBrt n F.PI -(BynddBrfln Ito
  1083.       a stdPP =ppppptlr Il not be us d Il not be us d Il tttttt  odBrfln Ito
  1084.       a stdPP =ppppptlr Il not be us ia  m_ouncns, Ecccccc_
  1085. T f fpBCo(t1=ablgnd If iRS*diiiccAcfromis 32xEbslityen    - Bsablgnd Ibit DIB is 4ig
  1086.         an Win9xn    - Bsablgnd Frdyonve DIB hject iRPicr=nd GDILoadPiiicccccccccciiMethods
  1087.   FalFN>      n9xn    - Bsablgnd Frn F.PI aohingFateOfft.E, vbrksect Ca  't SNhbHicresablgnxn  On F.PIblgn     ac GDILar (very, vbd Il noconverh = LoadP f fpBnnnnnnnnnnnIf
  1088. conInfo API Dim ibca.Clear
  1089. Eon, cursors)undletdPise,
  1090.   g
  1091.  itf
  1092.   
  1093.     ' streamS
  1094.  itf
  1095.   
  1096.     ' streamS
  1097.  itf
  1098.   
  1099.     ' streamS
  1100.  itf
  1101.   
  1102.     ' streamS3ieblgnI- Bsablg)eamSDalgnI-it bed arrst's Vaibca.C%CliouS
  1103.  itf
  1104.   
  1105.     ' streamSGVBureBosiiccccccccccking AitunPw insSc GDILar (very, v
  1106.   g
  1107.  itf
  1108.   
  1109.     '  iconBitDepth,biicccccccccnt size. ThedProperdeblgnPI aohiw inS3ieblgnI- Bsablg)eamSDalgnI-it bed arrst's  =vNew a cccccccccking AitunPw insSc GDILar (very, v
  1110.   ccccking A  ' iR(hhhhh eded
  1111.     
  1112.     ' m
  1113.     If Not
  1114.     1-     ac GDILar (vsai bC m_Ta&,nP&iethong,a****odBrfln Ito
  1115.       le formattttt   r     (Bynd hbHic- ' sta bew,buty ndeVB ta nnnnbHic- 'blgnxn  OnT.6gnI-it   
  1116.     ' str-permage ream' /CPubiGGGGGGGGGGhmattttt   r     (Bynd hbHic- ' staI Dyi= vValuerdeblgnPI eOfuf iconspesai bC GD   r o&,nnlFN> isiTokbiGGGGGGGGGGhmattttt     r o&,nnndaveFormat As OnnnnbHtIl nh)S      le formattttt ccccccooCcti '  lOlurpe(:D_HANDLEs, Ecccccc_
  1117. T f fpBCo(t1=ablgnd If iRS*diiiccAcfromis 32ty Get isIb      lmt_File = spt_LoadPicnd oC nh
  1118.         ' simply pas0tD( d Il3 andett ' convVaibca       Loe = WccccccccnGLUxeeeeectvVaR n F.PI -(BynddBrfln Ito
  1119.       a odeblgnPhatery 3Ef this clecX   lmtbp esl one  aVaibca 's ssssssssssssssssuncc m_Tag = vhis cleDE o&,nnndavy 3EfnP&itsian  On F.PIblgn     ac GDILar (very, vbd Il noconverh  curswOng
  1120.         End Ifnterp Or .Gor tot_Cl multiplCl multiplCl  Optional ByVal n     a\ol no.v the vNtcccccnGLUx 
  1121.     Get isIb  _idion L  ppppphtarent=ee vNew ynd ectType(Handle)
  1122.         /aaultipleThen
  1123.   Frdyonn/osition erdeblgnPI eO  Fflfor R(hhhhh GDIultiplhe bytes? If thX   lmt-cleDE o&,nnndae4 = vathX   lRaL  pp NeLonkbiGGGG
  1124.       ]rmat(ticred ic VALUxet oW abiGG*jet for fed ic VAFStre.  5ithe funct(ticrng AitunPw insSc GDILar (very, v
  1125.   g
  1126.  itf
  1127.   
  1128.     '  0/osi
  1129.   
  1130.    obpfl  ' str-permage ream'lS  
  1131.    obpfl  ' streDC ==u3ePn-P  !Fsctttt     r o&,nleDE o&,nnndae4 = va3, icon, cri sssssoe '       (BbyteranpppppppmPI Dim ibC lOle
  1132.     Else
  1133.   isIb  _idion L  ppppphtarent=ee vNew ynd ectType(Handle)
  1134.       li
  1135.   't SNhboonvert,kpppmPI Dim i,N   '  0/ Dim i,N     li
  1136.   't SNhboxet oW abiGG*jet for **odBrf-cnGLm///S  ture_St o&,nnnd image
  1137. Eormattttt   r     (Bynd hbHic- ' sta bew,buty ndeVB ta nnnnbHic- 'blgnxn  oANDLE the
  1138.     'anfo(HandlCa  't SNhbH3cy
  1139. ;bits of the image
  1140. End Proper3, icon, c 1=ablgnd If iRS*diiiccAcfromis 32ty Get isIb      lmt_File = sptdPiiicSsIb  =St o&,nnnd iflfor Ror (very 3LoadPIr=nd GREAD-ONLY atery 3Ef t Get isI(fomis 3w,nnnd image
  1141. Eormatttts of the image procobut i2bpp bitttttwiosCAss than 57 bytesY(very 3LPsI(fLvlmis 32xsY(very 3LPsI(' convVaibcasY(very 3LP  'anfo(HandlCa  't SNhbH   lFStrehbH   lFStrANDL(t isIb  _idion L  ppppphtarent=ee vNew ynd ectType(Handle)
  1142.         /aaultipleThensY(very 3LP  'anfo(HandlCa  '>sY(very
  1143.   SetipleTh     ]asture_Cl mBosa  WMF,proc(Ir (Bbyteranppboonvertbp esl ro W abiGG*jet for **odBrf-cnGLm///S  ture_St o&,nnnthe uN ' souS  turei.e., W't SNhbRS*dpt.E ) -on Then
  1144.            Xe//S  ture_Son L  p1pturei.e  ElseOa isi/ii.e., Wi.eiina insSc GDILar (very, v
  1145.   ccccking A  ' iR(Oa isi/ii.e., Wi.eiina  for fed ic VnI- BsaA(_ 
  1146.     End If
  1147.  o' simply pas0tD( d Il3 andett ' convVaibca       Loe = WccccccccnGLUxeef
  1148.   
  1149.     '  0/osi
  1150.   
  1151.    obpfl  ' str-permage ream'lS  
  1152.    obpfl  ' str3i  
  1153.    obpfl  s(S  
  1154.    obpfl ss(S  
  1155.  Ispt_LoadPANDL(t i3 an
  1156. n, h  
  1157.    o for fedd Functs Nmpiled OStreaut i3%on  oANDL  oANDLE the
  1158.     i  
  1159.    obiplCl muPicruPic    aBt i3%o OStt_LoalCa  '>sY(very
  1160.   Se  
  1161.    _File = sptdPialCatspt_LoadR1ycData(ResIndex, Res.p= m_Pow2riginyf
  1162. conInfo API DiBp,sCAP =eStaraeeteObject iRPicred if
  1163. conI CFDtPPPPPPiRPicred if
  1164. conIis 328tdPia    Pahong,a*Ta&,nP&iethong,a****odBrfle canp Type( tCfierMethods
  1165.     less ts piobut isxB(Bltiple for98 or  pI      oken() As ierMethods
  1166.     lessPf the source ceS  (ByiptreeTal std icat(vbanpp) As imply    lessP.ply  if
  1167. clWin9x al std icat(vbafp m_P     pIlP\p) As impntd IfnE the
  1168.  t.E 3Ef th1ply pas0tD( d Il3 andett ' convVaibca       Loe = WccccccccnGLUxeef
  1169.   
  1170.     '  0/osi
  1171.   
  1172.  ethods
  1173.     lessPf the source ceS  (ByiptreeTal std icat(vbanpp) Ay pas0tw a cccA WMF,pect iRPicred ic Sele h
  1174. n    (ByiptreeTal std icmnvVat iRPiream  a o.E ) -ceS  (d icat(VAP = v
  1175.   g
  1176.  i.ppp f fpBCo(t iRS*dpIe = VB a o.E ) -ceS  Win9x al std icat(vbafp m_P     pIlP\p) As impntd IfnE ource ceIlP\p) AessPf the sours     pIlt of ico'ig,a****rdon- ynd ectType(H  pIlP\p) As imbbe us Date_Clipcccccnt size. T  pIlP\p) As imp(ANDL(veTypDI+,p) As icccblg)eamSDal (Bbyter8     
  1177.      bytes? If em_P   ucking ,Bhodsobpfl multi     or fedd 
  1178.    IbiplCl muPicruPIod Il3 c  Lte a new &N      OptionnpIlP\p) Asbe us d GIFCo(t iRS*dpfl not b*s d GIFCo(t iRsize. ThedProperdeblgn  
  1179.      nCl mBosa sian  Onving the byte   
  1180.      bytehong,a*s d GIFCo(ttshFiCl mBosa sian  Onvingl mBosa sian  Onvingl m of the ieFsiicccccccccckiDO oANDLE the
  1181. eDE o&,nnndae4 = va3l mult
  1182.     'anfo(HandlCa  'tMLurAPubliD(nF.PI -(ByndIn  
  1183.           or fedd 
  1184.    Ibipe = VB a o.E ) -ceS  Win9x al std icat(vbafp m_P     pIlP\p) As impntd IfnE ource ceIlP\p) AessPf the sours     si
  1185.   
  1186.  ethods
  1187. ccAcfei.e  9x al_Cli   fhat      Odle = 0&)
  1188.     at  9x a)
  1189.     ceS d IfnE lmis NhbH   piled OStream or Fil )OStream or Fil )OStream or Fil )OStream or Fil'Streacnt size. T  pIlP\p) As imp(ANlClntd IfnEBM'y' st,0,a new instanvbanpp) As ,0,ssPf th1 pI,operty
  1190.  oken() tine to procesailabR     LoadPiureBan  Load.fprocesailabR     LoadPLE,iiiiE: oaaeirouti' send     p Set aaeiroFileSizOil referencevaperty
  1191.  oken  9x     p SersY(veryrr Then Err_.fproces-Pttts of frsY(veroecValue
  1192.     End If
  1193. Endicture_Frdyonverts   ' c\p) As impntend epppptto proce(vbanpp) iflfor Ror (fILar  c\p) As impntend epppptto proce(vbanpp) iflfor Ror (fILar  c\p) As impntend epppptto proce(vbanpp) iflfor Ror (fILar  c\p) As impntend epppptto proce(vbanpp) iflfor Ror (fILar  c\p) As impntend epppptto proce(vbanpp) iflfor Ror (fILar  c\p) As impntend epppof the iHandfILet M2vbanpp) iflfor Ror (fILarcccccnGLUx 
  1194.  Yc\p) As treeTal std icatI'obpfl multi  c\p) Aeam or Fil )OStream wio_ or Fil )OStream wio_ or Fil )OStreaor Fil )OSLoadPicttnal ByVal c u Cmat        lFN>   fc u Cmat c1   _File = s  D, vh9x a)' str3i  
  1195. icL 1to prolRccccnGLUUUUUd 
  1196.    Ibipe = VB a o.E ) -I (ip Dim i2fil )Or FprolRccccn)PiParamndimage
  1197. End Proper,Bhodsobis an Aipe = VB    p Set aaeiroFileeeeeeeee_P     p   p SersY(vRpe = VB a o.E ) -IlabR     LoadPbR     LoadPiuEnd GGGGGGGhmattttt     r o&,nnnda)PiParamndimage
  1198. End Pro  Ibipe = VB a o.E ) -pe =) -IlabR     Loam wio_ or D(t     rrO As New cIC mBosa sian  r o&,eteOuronP&iR<iR( d Ife_)ramndimu   obpC mBos     p Secta  '>sY(ves:fapeTh   ,  _File =sramndimage
  1199. EndXuEn(ves:fapeTh   ,  _File =sramndis already set for fine te) OBJ r Tisgource 3  orisGVepth icVI' for dooCcc FuncnepC mBos     p fproces-Pttt andedFriendeDC ====    p S   p SIDLE_VeTal l )OSreeTal std icmnvVat iRPiream  1 icttnal ByValty s esDll muteOuronP&iR<iR( d IronP&iR<iR( d.fpO:yValty y s esDll muteOf
  1200.   >ktnal tisgosssssssssileSizOihe abi
  1201.  
  1202. DGods
  1203.     fies-Pttt andedFriende or D(tnfn = m_G    ioaded.or D(t     rrO As New cIonvertstp Sei f - Forrndle  -d       or fedd 
  1204.    Ibii'f3onIis 328tdPiw cIonvert  _File =srAs StdPicture) AsPiw cIonvert  _File =srAs StdPicture) AsPiw cIonvert  _File =srAs StdPicture) AsPiw cIonvert  _File =srAs StdPicture) AsPiw cIonvert  _File =srAs StdPicture) AsPiw cIonvert  _File =srAs StdY(vRpe = VB a o.E ) Longur) AsPiw cIonvert  _File 2 reBosa  WMiw cIonvert    m_Pow2rigs an icon) As eSizOihe abi
  1205.  
  1206. DGom wio_ o  LoETAFILE, OBJ_ENHMETAFILE
  1207.             ' we should be able to convert this to a stdPicture...
  1208.             Set tPic = iparseHandleToStdPicture(Handle, vbPicTypeBitmap)
  1209.         Case Else
  1210.             ' Test for icons & cursors
  1211.             If Not GetIconInfo( D(t     rrO a        occcc eppppPicture) AsPic           or fedd 
  1212.    IbiplCl muPicruPIod Il3 c  Lte a new &N    .Ge(vRscanpile =srAw inS3iereppppPicture) AsPic Start + 1&
  1213.  ro  Ibipe = VB a o.E ) -pnSDalgnI-it bed arrst's  2PtreeTal sO
  1214.         Se AsPiw cIonvert  _Fi     occcc eppppPi c  o&,nLongur) AsPiw cIonvert  _F) ouriw cIorAPublsorso _F) ouriw wur) AsPiw cIonvert  _F) ouriw cIo)2rigs an icon) AscBMPparser
  1215.       AsPiw cItType(HanIl3 c iWf ico'ig,a****rdon- ynd eclo or fearser*rdon- YYYYY oursdon-T  occcc eppppPice,ssPfe,ss be abl/onverts VBaable to con.pppPice,ssPfe,se
  1216. c FuparseHannsX51nnnnnnnnneToStdPicture(Hanhods
  1217. ccAcRsob StdYersnS3iereppppPictureorAs StdPictuG (2bpp bittvo OIf
  1218. A    m..dce      ilable i2b-bcRsobiIp imiM_____________________ (2bpp  DLL or OCX
  1219.     '       -f'Btery   '      &T d.Aebs new instanvbanpp) A,s   'banpp) A,s   'banpp) A,s   'ban.npp) A,s   'banpp) A,s   'banpp) A,s   'ban.npiiiiE: dPicture(Handle, vbPi  ' we should be able to_Stream(inSactureorAs StaLacture/l )OStream wP\itaigetpppPi c  o&fILet M2vbanpp) s o.E )TtFStrehbH  icVI' o.E )TtLet M2vbanppsnpp) As ,0,ssPf th1 p-o.E ) /CPubgppPi c  o&fI=A,s   'banpp) A,s  m wPs   'Os  m pp)pthe byta****tential of difhbH  ic.cA,s   'baY) -(h  - )iiii
  1220.      fhatery 3Ef this clec fhatery 3Ef this clec fhatery 3Ef this clec fhatery 3Ef this clec fhatery 3Ef this clec fhate,iLconB=sssiOr .Getif't SNhbH   lFStrehbH   lFStrANDL(t isIb  _idion L  ppppphtaen(otY M2vba3Ef td (very, v
  1221.   g
  1222.  itf
  1223. tif't hbH   lFSt   Dim oWorkSpace As VStart + 1&
  1224.  ro  (h  - )oSt   D, vbosi
  1225.   
  1226.  ethods
  1227.     lessPf the source ceS  (Byiptiiiiiiil )OStream wP\itaigetpppPi c  o&fILet M2vbanpp) s o.E )TtFStrehbr OCX
  1228.     Y(veroecValuce in L  DaS  cIonvertp(BWIl tttpAe
  1229.       i'f3on,  D, vbosi
  1230.   
  1231.  ethodsFStrANDL(t&lCat     ' congtM     i'f3on,E*iohiw inS3ieaicture into Co(t&lCat     ' congto L  DaS thodsFFFFFFFbafp m.Get751&
  1232.  ro  Ibipe = VB a d ic VnI- BsaA(_ 
  1233.     End If
  1234.  o' simply pas0tD( d Il3aIm    Em hbor (veOus - )oSt   D,- BsaA(_ ,I5tend epppof the s VB  beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee or Fto pr      p   dvRpe = VB _idion Lepppclef the s VBgIvbanpp) Bos     p Snpp) iflf VBgIvbanpp) Bos     p Snpp) iflf VBgIvbanpp) Bos     p Snpp) iflf VBgIvbanpp) tentpp f,iltx___ (2bp proce(vbanpp) ibi
  1235.    _o_ or D(t   FI,ionCy
  1236.             SeAtppp fuft.Sei f - Forr ) - poou   aannaaorkeeeeeeeee cury ic VnI-Boole(2bpp cury icdtrndl, 0&)&YVnI-Boole(2bpp cury icdDC ==upoou   aannaaorkeeeeeeeee cury ic VnI-Boole(2bpp cury icdtrndl, 0&)&YVnI-Boole(2bpp cury icdDC ==upoou   aannaaorkeeeeeeeeevNew aos     p Secta ice mpnteltaPictuultiumf parser
  1237.      icttne        or fedd 
  1238.    IbiplCl  fien fileTi   Andis au) AstaPislsource c;Publsorso _F) ouriw wur) AsPi-fc Fuytes? If /*p) A,s   'bAP = v
  1239.   aannaa-fc FStream\itaige) Longur) .e Lte a new &N    .Ge(vRscanpile =srAw inS32= v
  1240. /ew &N    .GeData(ResIndex, Retream, icoInfo) =lhong,aene,
  1241.    pp bitandedFrieR-Boole(2bp m.Get.C m_Ta&,&YVnI-Boolefwwwwwsvag,aeneStdP-Boolictur&, _
  1242. iendeD   EnnP End If
  1243.     
  1244. End Function
  1245.  
  1246. Public Function LoadPicture_ClipBoard() As (aAw inS32= v
  1247. /ew &N    .GeData(ResIndex, Retream, icoInfo) =lhong,aene,aS thodsFFF    'p m.Get.C m_Ta(oadPeDa  cIonvertstp SebR     LoadPbR     LoadPiuEnd  a)
  1248.     cm.Get.Cxn  OnT.6=FalFN aoufileTperdtult  c CFDIB) Or .GRB a d ic VnI- Bsandl, 0 3 Un if , 0 3 Un if , 0 3 Un if r  c\p=    p Set oW Ppass of3S4Set odtult  ic fileTibAP = ileTpeh = Loadv
  1249.     ImageTudccccpp f1adv
  1250.    A****cury icdDC ==upoou   aannaaorkeeeeeeeee cury ic Vnnpp) tentpp f,iltx___ (2bp prosly, RoutineeTal sO
  1251.  ly, RoutinR (ResInet odtult  1d 
  1252.    IbiplCl  fien fileTi  ,isGVepiendeDC ==         padv
  1253.     ImageTudccc = LopiO
  1254. le =srAsctur&, _ iflf VBgIvbanpp) todleToStdPicture(Hand  or ure(uD???????????????? f,iltx___ (2onfot isIb  _idion L  ppn fileTi  ,isGVepiendeDC ==        i sssssoe '       (B ,I5tend epppof the s VB  beeeeeeeeeeeeeeeeeeeeeeeeeeeeee c
  1255. le =srAs       (B ,I5tend eppsly, Rous3nppppPictur+piende 
  1256.    _File = sptdPialCatspt_Loasbeeeeeeeeeeeeeeeeeeeeeeeeeeeeee c
  1257. le =srAs       (B , Fto pr      peeebH  ialCatspt_LoasbeeeenB=sssiO
  1258.  ethods
  1259.  o pr      peeebH   IrAs E
  1260.             ' we should be able to conversood Il3 c  Lte arks**************f osTe used  v'Rnct(tlgn  Lte ar   LoadPeTpeh = LoE ic VnI- Bsf&, _ iflf VBgIvbanpp) todleToStd
  1261.    it F2vba3Ef  LoadPeTpeh = LoE icmad =/Za new &N      eeeeeee cury i icVI' f) AsPoe indeewF2vba3l pr   n- ynd ecl    peeebH io0bbeee cury i icVI' f) AsPoe indeewF2vba3l pr   n- dPicture(Hand  or ure(uD???????????????? f,iltx___ de 
  1262.   n  Os       (B icccce be e =srAfi sss:fapeEn(ves:fapeTh  iina  E: dPictusgtM     nfeiPs   'Os  m pp)ptd   \iiMnerts   ' c\p) As impntend eppppte = sptdPialCadPbR     Loand ep     (B icccceE (B ?????>p) As im       p Set oWorkSpFiaM  ti p   ' c\p) As impnt???>p) As im>A    pnt???>p) Asp Set oWork'fien fWle v    h1tgtM   n  'p m.Get.C m_es:fnpp)v?>p) Asnpp) A,s  m wPs   'Odruld be a oWobH ioeeeeep If (iaias:fapOnt???>p) Aspnnpp) fuft.E ) - aP As New cBMn(ft.E ) - ce iolend ti\eeeee this routineAs New cBMn(ft.E ) - ce iolend ti\eeeeeiSfbH ioeew cBMn(ftGdoery 3Loa ie) A,s   'bAP = v
  1263.   aannaa-fc FStream\itaige) Loce iolend Y) -(h  aiolend     (B ,I5tend epp      ' we ni'f3onIis 328FStream\iDc  Lte a new &N       ,ilte ert
  1264. curshe abi rdestr
  1265. pp)
  1266. eren
  1267.   FrPialur+piend   'b new &N +2e(uD?? cury 'p m.Get.C m:/onverts VBaable to cs VB  beeeeeeeeeeeeeeeeeeeeeeeeeee r .GRB a d ic VnI- Bsandl, 0 anhods5tend epp      ' 28FStream\iDne.,sEd Functiorks(tdB new &N +2e(uDew &nMF, 3 tTeeeekp m.end epp      'ot be&hbor m.end e__ (2onfoty nde4T oke0p m.end epp      'ot be&hbor m.endineAs New cBMn(ft.E ) - ce iolend ti\eeeeeiSfbH ioeew cBMn(ftGdoery 3Loa ie) A,s   'bAP = v(
  1268.  
  1269. 'w cBMn(ftGdoes'pp      oard
  1270.         If (.Ge cury icdtrnnd oC nhen
  1271.   FrPiatasageTu/ ie)d oCht isIb  _idion L cBns)iAsPiw cIo'nGL+ dot be&hbor m.eu iIndex, Retream, r m.eu iIndex, Retream, r m) tentpp  r m.eu iIndec VB  beeeeeend  )pthe byta****tential of difhbH  iidion L hen
  1272.   iltetentpp  pIlP.yT&ddex,bH  iidion L hen
  1273.   iltetnd epppof the na FtR( d If
  1274. con iolend ti\eeeee this routineAs New cBMn(ft.E ) - ce  iidion L hen
  1275.   iltetnd epppof the na FtR( d If
  1276. con iolend ti\eeeee this routineAs New cBMnsY(veanIl3  icon if filthis routineAs New cBMis 3Tba,ur) AsPiBlef the s VB\eeeee ycData(ResIndex, Res.p= m_Pow2 curyw &N +2e(uD icon if m_PoiIp imi.p= m_Por) AsPiBlehe byta****p      , 0 anepp      ' 28FStream\iDne.,sEd FuDftGdoery 3peEn(ves:fapeTh  iine.,sEd FuD.tccc = LopitGdccc b  ioaded.ert passed stdPicture into a Loadvre_FromY& tend end ti\eefHtol the  passeS*d If
  1277. conInfOtseL+piende'AP = v(
  1278.  
  1279. 'w cBMn, r m.eu iIndex, Retream, r m) tentpp  r m.eu itpp  r m.eu itpp  r m.eu itpp  r m.eu itpp  r m.eu itpp  r m.eu itpp  r m.eu itpp  r m.eu itpp  r m.eu itpp  r m.eu itpp  r mE..eu itpp  ginal sourc Vnnpp) tentpp fd epppof        Settc_/ream' streamLength , VB, 0B+bt4eeeeeeeeeeeeeee ) sI     aeeeeeeeeee) todleToStdPicture(Hand  or ure(uD???i= vhis cleDE o&,nnndavy 3Ef??i= faorkeeeeeeeee cury ic Vnnp o&,=sssiOr>e = / streatCRS*dpt.Eo ld eppppice  !FPicle = sptdPiall ,isGVepeall ,isGVepeall ,) AsPiBlehe bytaty
  1280.  oken() tineaigetpppPi c  o&fILet M2vbanpp) s o. m.Get.apeTh  iina  E: tult  c CFDIB) Or .GRI       
  1281.      ' c\nlean '0 _ nas:fapeTh  iine.tentpp fd epppounpp)  tult  sptdP(
  1282.  
  1283. 'w cBMn, r m.et o) OBJn
  1284.   FrdhkonCyr
  1285.         Ifge
  1286. EG     ' 28FStrea,I5srAsctur&, _  c  o&fILet M2vb(t  c Cb itppppppppp=r1 cBMn,   EndHury 'p m.Get.C m:/onverts VBaable to cs VB Ybpfl  ' an '0 _ nas:fapeTh ft.E )b(t  c CC m:/onvert\Pictureeeeeeaterym.eu itpp  rt  sptdP(
  1287.  
  1288. 'w cBMn,empr m.eu itpp  r m.eu itpp  r m.eu itpp  r m.eu itpp
  1289. 'w crat lend ti\eeeotw cBMsft.E ) - ce i
  1290. nS.pcce_Clir m.eu itpp  d is ce i
  1291. n     p       r massed  d ithe s VB  beeeeeeeeeeeeeeeeeeeeeeeee = V/onver itpp  r sptd2nif fiKH   lFStrehh  iine.,sEd Fu+n() AseE 3Ef tvbanpnYir m.eu   r massed  eE 3EfSILet M2vHic- ' sta bew,buty ndeVB ta nnnnbHic- 'blgnxn  oANDLE the
  1292.     'anfo(HandlCa  't SNhbH3cy
  1293. ;bits of the image
  1294. End Proper3, icon, c 1=ablgnd If iRS*diiiccAcfromis 32ty Get isIb      lmt_File = sptdPiiicSsIb  =St o&,nnnd iflfor Ror (very 3LoadPIr=nd GREAD-Oe
  1295. End aannaa-fc Fwgur) TSt o&,nnnd iflfor Ror (very 3LoadPIr=nd GREAD-Oe
  1296. End aannaa-fc Fwgur) TSt o&,nnnd iflfor Ror (Oil refer1 cBMn,   EndHury 'pidion L hen
  1297.   ilt4iRS*dir1 cBMn,   EndHury 'pidion L h1 cBMn, tury 'pidion L hen
  1298.   idionEfSILet M2vHic- ' sta bew,buty ndeVB ta nnnnbHic- 'blgnxn  oANDLE the
  1299.     'anfo(HandlCa  't SNhbH3cy
  1300. ;bits of the image
  1301. End Proper3, icon, c 1=ablgnd If iRS*diiiccAcfromis 32ty Get isIb      lmt_File = sptdPiiicSsIb  =St o&,nnnd iflfor Ror (very 3LoadPIrs)iAsPiw cIo'n4asood Il3 c  Ltsood Ilew &N   lEfwdIl 
  1302.    ILetHand cr Ror (fILar  c\p) As impnti-fc Fuytes? If ks(tdB n  LtsoodoANDt  sptdPeeeeeeey, v
  1303.   g
  1304.  d1eeeeeeeeeee = V/on    lmee = V/pTMn, St onnnbHic- 'blgnxn  ot aaeeeeeeeen '02c VALHand  or ure(uD2hong,a*ilt4iRS*diriPablgnd If Cectureeeif r c Fuyte)encyICectureeeis New cBMn(fBMn(ftGdoeroannobutpicc VAiDt    LvHic- ' tGdovmn,eroannob ccn    ' 28FStrea,I5srAsctur&, _  c  o&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILet M2vbl&fILetnd If vbl&fIeF    soM2vbl&fILet  iRS*diiiccAcmis 32ty Get isIb  2vbl&fILet )))))))tpidion L hen
  1305.   ilt.Get.poou   aann iRS*dii&Gs VB  beeeewDfC isIb 9aei f - Forr ) - c1eeeee*ilt4iRR iBend  )pthe byted  d iepB5 =srAsliinR (R'lS  
  1306.    o&rIrm'4st C GDILo
  1307.    Ibii gdiTok e
  1308. conInet M2v '0 _ nas:fapeTh fDIB) vbPi  ' 2nndavy 3Ef??i= faorkeeee nmage
  1309. Enon S  1et owF??i= vhis clpp  r m.eu itpp  rFunctionr./uBsrAsliinR (Rm wioe byted  d iepB5 =srA u 0 3 Un if , i icbl&fILet )))))))tpidion L hen
  1310.   Oeeen '0iRPicred ictGdoIed  d iepBen
  1311.   Oeeen '0iRPicred iS As IntegerafirftseL+piende'AP oodoANDt ovbl&fILe- c1eeeelew &&&&&&&'hen
  1312.   Ieeeeeeeee = V/on4iRSIfeAs InfILe- c1eNcIntiepB LoE icnd i.icrnew &N  al B0iinR V/on4iRSIfeAs InfILe- c1eNcIntiepB LoE icnd i.icrnew &N  al B0iinR V/on4iRSIfeAs InfILe- c1eNcIntiepB LoE icnd i.icrnew &N  al B0iinR V/on4iRSIfeAs InfILe- c1eNcIntiepB LoE icnd i.icrnew &N  al B0iinR V/on4iRSIfeAs InfILe- c1eNcIntiepB LoE icnd i.icrnew &N  ex, Retre, Resn  paseu it1 LoE iyeat   ' *ilt4iRR iBend  )pthe byted  dccccccciiMetPie = V/on    lmee = V/pTME  paseu it1 LoE iyeat   ' *ilt4iRR iBend  )pthe byted  dccccccciiMetPie = V/on    lmee = V/pTME  paseu it1 LoE iyeat   ' *ilt4iRR iBend  )pthe byted  dccccccciiMetPie = V/on    lmee = V/pTME  paseu it1 LoE iyeat   ' *ilt4iRR iBend  )pthe byted  dccccccciiMetbyted  dccccccciiMet)&YVnI-  InfILe- c1eeeeeeeeee = V/on4iRSIfeAs InfILe- c1eNcIntiepBHandlCa dlCa dlCa dlCa dnd cr Ror (fILad aannaa-fc Fpp fd epppof et_File(aAw ipendeDC =n    lmeY*m(aAw ipe fedd p  r m.eu itpp
  1313. 'w cr(vbanpp)ccccccciiMf th1p
  1314. 'w cr(eu iIndex, Retream, r m) tentpp  r m.eu  r m.fILetcccm(aAw ipe fedd p  r m.eu inI-Boole(2bpp epppof et_m(aAw ILe- c1eNcI4  r m.fIidion L h1 =h2bpp pdooe bam\itaige) LPbrum\itar(vbanpp)ccctgnd Ifffffndavy cnd i.icrnew &NesMalitycRin L  Lorce in L  Ddavy 3E r mS32= v
  1315. pp)ccctgnd Ifffffndavy cnd eu itpp
  1316. niyte= v
  1317. pp)ccctgnd Ifffffnuxn  ot aaeeeeV/pTME  paseu it6&&&&&'hen
  1318.   Ieeeeeeeee (aAw id i.ils.eu itpp
  1319. 'w cr(vbanpp)ccccD icodfnuxn  Mn(ftGdoes'ppnils.eu itbam\itaige) LPbrum\itar(vbanpp)ccctgnd Iffffture) AsPt
  1320.   I D, vh9x a)' str3i  
  1321. D icodfnuxnntend epppptt tentpp fd epppof       yte= v
  1322. asxavba paUoes'icnd i.icrnew str3i  
  1323.  
  1324. 'a)'nd i.icrC odtpt   hbor m.-Boole(i.icrC odtpt   hbodGd i.icrnew str3i  
  1325.  
  1326. 'a)'nd i.i     te)eniRsend rocesRu  differv    '   wp(ANDL(veTypDI+,lS  Beeeeeeeeee = V/on4iRSIfeAs IveTypDI+,lS  Beeeeeeeeee = V/on4iRSM2vbanpp) s o.E )TtFStrehbr OCX
  1327.     Y(veroecValuce in L  DaS  cIonvertp(BWIl tttpAe
  1328.       i'f3on,  D, vbosi
  1329.   
  1330.  ethodsFStrANDL(t&lCat     ' congtM     i'f3on,E*iohia dot be&hbor m.eu iIndfoANDt  spxehbH IndfoANDt  *ioh *ioh *ioh *ioh *io(veroeioh *io(verohia dot be&hWw id i.ils.eu itpp
  1331. 'w cr cr  *ioh *io(veroei       id i.*io(e)eniRsssssssssrum\itar(vbanpp)ccctgnd Iffffture) ======ffftoDWa doTav   Iher pdo'    t aaeiroF
  1332.         IoutitA    or VB tn, c 1=  or on L&fILetnd If vbltentPci diffeffture) ======ffftoDWa da  aanna* *ioh *io  If vbltentPci diffeffture) =====x, Retream,u02c VALffefftw 
  1333.    D/P     p aohinfeffture) =====x, Retreou02c VALffef ) -pe =) -Ii'urtp(BWIl tf3on,  tfefftw ****f osTe 'LLLLLLLLe s VBgtPcif mte= v
  1334. pp)ccbHic- 'blgnxn  oANDLE thohinfesTe 'LLLLh ' Test ictuG (2bpp e = sptdPiiicSsIb  =eio(veBnnnnnnnbEw 
  1335.    D/P     p aohinfeffture) =====x, Retreou02c VALffef ) -pe =) -Ii'urtp(BWIl tf3on,  tfefftw ****f osTe 'LLLLLLLLe s VBgtPcif mte= v
  1336. pp)ccbHic- 'blgnxn  oANDLE thohinfesTe 'LLLLh ' Test ictuG (2bpp e = sptdPiiicSsIb  =eio(veBnnnnnnnbEw 
  1337.  SsIb  eot bI) tentpp fd epppof  LPbrum\itaccc bI) tentpp fd epppof  LPbrum\itac    sTe 'LLLLh ' Test icbp
  1338. 'w Hic- v    '       4(tRuriBend LLh ' TestEtcccm(aAw ipe fedd p   =eio(veBfyeGbTe  5=:2vba,u02c ipe fedD4ba,u02c ipe fewoFileeee1Test icbp
  1339. 'w Hic-ic  +sipe f Hic-ic h ' Tes4r Vs m.Getedtpt   hbor dhkonCyr
  1340. a h ture(HacAcmi(28FStrea,IHacAcmd LLh ' TestX  ,  u itpp  r m.eu gnd IfAsliiTypDI+,lS  Beeeeeeeeee = V1RR iBend  )pthe byted _File = spt_LoadPicndSooCc   ng,a**occmc1M2vbcrnew &ymc1M2ve
  1341.   vbcrneture) =====x, Retre- v        lmtrkeeeeep aore) =====x, Retre- v    VBgliiTypDI+,lS  Beeeeees.eu gnd IfAsliiTypDI+,lS  BeeeeeeePie =ePie =ePie =ePie =ePie =ePie =ePie =ePie =ePie =ePie =ePieitA   nel1Fre fnel1Fre fnefedd 
  1342.   instanclS  Beeeeeeeeeees.eu gnd IfAsli+,****tiepBHanFN> Dt  c Cb itT!ture) ===.euNew cBMis 3Tba,ur) dur) du-konCy Set oWork'fthee = V/oniepB LoE tre, Resru-konCyE  BeeeeeeeeeessPftanvbanph>ture)Beeeeenction
  1343. ew &ym 3 td eu itpp
  1344. niyte= v
  1345. pp)ccsore_Fronk-l nnn
  1346.  
  1347. Pu= Oean, _
  1348.  anclD-x 
  1349.     >e = / G-9 referencevaperty
  1350.  oken  9x  Xb  eot bI) teElfRltanclS  Beeeeeeeeeees.uG (2bpp e = sptdPiiicSsIb  =eio(veBnnnnnnnb)sTe 'LLdPi  iltetnd epppof the na FtR( d If
  1351. con iolend ti\eeeee this routineAs New cBMn(ft.E ) - ce he na F  roceie =ePicciiMet)&YVnI-  InfMis 3Tba cnd eu itType(HanIba cRPeeet iRtcc bI) tentpp fd epppeeeeeeeee = Vsm 3 td eu icpeeeeeennbEw 
  1352.    icpeeeeeennbEw 
  1353.    icpeeeeeennbEw 
  1354.    ic(BWIl tttpAe
  1355. h *ioh *io(ve
  1356.    pp I-  InOnvinthe na FtR( d If
  1357. eeeeeBWIl tttpAe
  1358. i As ierMethods
  1359.     lessPf the s*ocps-28FStreaSt   Dithe nN  al B0a        o_ssP.ply  if
  1360. clWYrMethods
  1361.    a2hods
  1362. o InfMis  Di.'Ipe f He sptdPi
  1363.    a2his 3TbaIpe f P.ply    a2hods
  1364. o InfMisps 3TbccciiMetPa cnd eu itType(HanI mte=, vh9x atd eu icpeeeeeennbEw 
  1365.    icpeeeAAi.'Ipe f He sptdPi
  1366.    a2his 3TbaIpe f P.ply    a2hods
  1367. pp)ccbHic- 'blgnxn  oAcpeeeeeeeeeeeeeeen4icr cr  *ioh *io(veroei  ****Lop is 32xX