home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 4_2005-2006.ISO / data / Zips / PNG_Reader19586512212005.psc / frmPNGmenu.frm < prev    next >
Text File  |  2005-12-21  |  45KB  |  1,192 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  3. Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
  4. Begin VB.Form frmPNGmenu 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "PNG Load and Options"
  7.    ClientHeight    =   5685
  8.    ClientLeft      =   45
  9.    ClientTop       =   330
  10.    ClientWidth     =   3135
  11.    LinkTopic       =   "Form2"
  12.    MaxButton       =   0   'False
  13.    ScaleHeight     =   5685
  14.    ScaleWidth      =   3135
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CommandButton cmdWrite 
  17.       Caption         =   "PNG Writer"
  18.       Height          =   315
  19.       Left            =   45
  20.       TabIndex        =   42
  21.       ToolTipText     =   "Select PNG File"
  22.       Top             =   5340
  23.       Width           =   3060
  24.    End
  25.    Begin TabDlg.SSTab SSTab1 
  26.       Height          =   4710
  27.       Left            =   30
  28.       TabIndex        =   1
  29.       Top             =   390
  30.       Width           =   3090
  31.       _ExtentX        =   5450
  32.       _ExtentY        =   8308
  33.       _Version        =   393216
  34.       TabOrientation  =   2
  35.       Tabs            =   4
  36.       Tab             =   3
  37.       TabsPerRow      =   4
  38.       TabHeight       =   520
  39.       WordWrap        =   0   'False
  40.       ShowFocusRect   =   0   'False
  41.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  42.          Name            =   "Tahoma"
  43.          Size            =   8.25
  44.          Charset         =   0
  45.          Weight          =   400
  46.          Underline       =   0   'False
  47.          Italic          =   0   'False
  48.          Strikethrough   =   0   'False
  49.       EndProperty
  50.       TabCaption(0)   =   "&Canvas"
  51.       TabPicture(0)   =   "frmPNGmenu.frx":0000
  52.       Tab(0).ControlEnabled=   0   'False
  53.       Tab(0).Control(0)=   "txtAlphaBlend"
  54.       Tab(0).Control(1)=   "chkAutoErase"
  55.       Tab(0).Control(2)=   "chkAlphaBlend"
  56.       Tab(0).Control(3)=   "Label2"
  57.       Tab(0).Control(4)=   "lblBkg(3)"
  58.       Tab(0).Control(5)=   "lblBkg(2)"
  59.       Tab(0).Control(6)=   "lblBkg(1)"
  60.       Tab(0).Control(7)=   "lblBkg(0)"
  61.       Tab(0).ControlCount=   8
  62.       TabCaption(1)   =   "&Size && Pos"
  63.       TabPicture(1)   =   "frmPNGmenu.frx":001C
  64.       Tab(1).ControlEnabled=   0   'False
  65.       Tab(1).Control(0)=   "Label1(0)"
  66.       Tab(1).Control(1)=   "Label1(1)"
  67.       Tab(1).Control(2)=   "Label3(3)"
  68.       Tab(1).Control(3)=   "txtImgXY(1)"
  69.       Tab(1).Control(4)=   "txtImgXY(0)"
  70.       Tab(1).Control(5)=   "txtScale(1)"
  71.       Tab(1).Control(6)=   "txtScale(0)"
  72.       Tab(1).Control(7)=   "chkScale"
  73.       Tab(1).Control(8)=   "chkRatio"
  74.       Tab(1).Control(9)=   "cmdApply"
  75.       Tab(1).ControlCount=   10
  76.       TabCaption(2)   =   "Prg &Display"
  77.       TabPicture(2)   =   "frmPNGmenu.frx":0038
  78.       Tab(2).ControlEnabled=   0   'False
  79.       Tab(2).Control(0)=   "Frame1(1)"
  80.       Tab(2).Control(1)=   "Frame1(0)"
  81.       Tab(2).Control(2)=   "Label3(2)"
  82.       Tab(2).Control(3)=   "Label3(1)"
  83.       Tab(2).ControlCount=   4
  84.       TabCaption(3)   =   "PNG &Info"
  85.       TabPicture(3)   =   "frmPNGmenu.frx":0054
  86.       Tab(3).ControlEnabled=   -1  'True
  87.       Tab(3).Control(0)=   "lblInfo(0)"
  88.       Tab(3).Control(0).Enabled=   0   'False
  89.       Tab(3).Control(1)=   "lblInfo(1)"
  90.       Tab(3).Control(1).Enabled=   0   'False
  91.       Tab(3).Control(2)=   "lblInfo(2)"
  92.       Tab(3).Control(2).Enabled=   0   'False
  93.       Tab(3).Control(3)=   "lblInfo(3)"
  94.       Tab(3).Control(3).Enabled=   0   'False
  95.       Tab(3).Control(4)=   "Label3(0)"
  96.       Tab(3).Control(4).Enabled=   0   'False
  97.       Tab(3).Control(5)=   "lblInfo(4)"
  98.       Tab(3).Control(5).Enabled=   0   'False
  99.       Tab(3).Control(6)=   "Text1"
  100.       Tab(3).Control(6).Enabled=   0   'False
  101.       Tab(3).Control(7)=   "chkShowInfo"
  102.       Tab(3).Control(7).Enabled=   0   'False
  103.       Tab(3).ControlCount=   8
  104.       Begin VB.TextBox txtAlphaBlend 
  105.          Alignment       =   2  'Center
  106.          Height          =   285
  107.          Left            =   -72885
  108.          MaxLength       =   3
  109.          TabIndex        =   4
  110.          Text            =   "255"
  111.          Top             =   4140
  112.          Width           =   840
  113.       End
  114.       Begin VB.CheckBox chkShowInfo 
  115.          Caption         =   "Show this tab after PNG shown"
  116.          Height          =   240
  117.          Left            =   405
  118.          TabIndex        =   45
  119.          Top             =   4380
  120.          Value           =   1  'Checked
  121.          Width           =   2625
  122.       End
  123.       Begin VB.Frame Frame1 
  124.          Height          =   1680
  125.          Index           =   1
  126.          Left            =   -74520
  127.          TabIndex        =   31
  128.          Top             =   2970
  129.          Width           =   2400
  130.          Begin VB.CheckBox chkIL 
  131.             Caption         =   "Non-Interlaced PNGs Only Always use scanner effect"
  132.             Height          =   420
  133.             Left            =   75
  134.             TabIndex        =   35
  135.             ToolTipText     =   "Automode will apply effect if image is > 1/3 screen size"
  136.             Top             =   1155
  137.             Width           =   2235
  138.          End
  139.          Begin VB.OptionButton optIL 
  140.             Caption         =   "Fade-In (non Alpha Only)"
  141.             Height          =   210
  142.             Index           =   2
  143.             Left            =   75
  144.             TabIndex        =   33
  145.             ToolTipText     =   "Note: If Alpha, then Fade In is also the Default"
  146.             Top             =   525
  147.             Width           =   2175
  148.          End
  149.          Begin VB.OptionButton optIL 
  150.             Caption         =   "Don't Progressive Display"
  151.             Height          =   210
  152.             Index           =   1
  153.             Left            =   75
  154.             TabIndex        =   34
  155.             Top             =   855
  156.             Width           =   2175
  157.          End
  158.          Begin VB.OptionButton optIL 
  159.             Caption         =   "Auto Mode"
  160.             Height          =   210
  161.             Index           =   0
  162.             Left            =   75
  163.             TabIndex        =   32
  164.             ToolTipText     =   "Alpha=FadeIn,Non-Alpha=Pixelated,Non-Interlaced=Scanner if >1/3 screen size"
  165.             Top             =   210
  166.             Value           =   -1  'True
  167.             Width           =   2175
  168.          End
  169.       End
  170.       Begin VB.Frame Frame1 
  171.          Height          =   1980
  172.          Index           =   0
  173.          Left            =   -74550
  174.          TabIndex        =   25
  175.          Top             =   540
  176.          Width           =   2520
  177.          Begin VB.OptionButton optTrans 
  178.             Caption         =   "Use the Transparent Color"
  179.             Height          =   210
  180.             Index           =   4
  181.             Left            =   45
  182.             TabIndex        =   28
  183.             Top             =   1095
  184.             Width           =   2400
  185.          End
  186.          Begin VB.OptionButton optTrans 
  187.             Caption         =   "Don't allow any transparency"
  188.             Height          =   210
  189.             Index           =   3
  190.             Left            =   45
  191.             TabIndex        =   30
  192.             Top             =   1710
  193.             Width           =   2400
  194.          End
  195.          Begin VB.OptionButton optTrans 
  196.             Caption         =   "Use another Color"
  197.             Height          =   210
  198.             Index           =   2
  199.             Left            =   45
  200.             TabIndex        =   29
  201.             ToolTipText     =   "Click ellipse to select a color"
  202.             Top             =   1395
  203.             Width           =   1635
  204.          End
  205.          Begin VB.OptionButton optTrans 
  206.             Caption         =   "Use Suggested Window Bkg"
  207.             Height          =   210
  208.             Index           =   1
  209.             Left            =   45
  210.             TabIndex        =   27
  211.             ToolTipText     =   "If no BKG color provided, white will be default"
  212.             Top             =   810
  213.             Width           =   2400
  214.          End
  215.          Begin VB.OptionButton optTrans 
  216.             Caption         =   "Always transparent"
  217.             Height          =   210
  218.             Index           =   0
  219.             Left            =   45
  220.             TabIndex        =   26
  221.             Top             =   210
  222.             Value           =   -1  'True
  223.             Width           =   2235
  224.          End
  225.          Begin VB.Label Label1 
  226.             Caption         =   "Following destroys Alpha info..."
  227.             ForeColor       =   &H000000C0&
  228.             Height          =   225
  229.             Index           =   2
  230.             Left            =   90
  231.             TabIndex        =   46
  232.             Top             =   525
  233.             Width           =   2325
  234.          End
  235.          Begin VB.Label lblShowColorDlg 
  236.             Alignment       =   2  'Center
  237.             Appearance      =   0  'Flat
  238.             BackColor       =   &H00808080&
  239.             Caption         =   "..."
  240.             ForeColor       =   &H80000008&
  241.             Height          =   195
  242.             Left            =   1725
  243.             TabIndex        =   36
  244.             ToolTipText     =   "Click to select a color"
  245.             Top             =   1410
  246.             Width           =   420
  247.          End
  248.          Begin VB.Label lblBkgColor 
  249.             Appearance      =   0  'Flat
  250.             BorderStyle     =   1  'Fixed Single
  251.             ForeColor       =   &H80000008&
  252.             Height          =   225
  253.             Left            =   1710
  254.             TabIndex        =   41
  255.             ToolTipText     =   "Click to select a color"
  256.             Top             =   1395
  257.             Width           =   690
  258.          End
  259.       End
  260.       Begin VB.TextBox Text1 
  261.          Height          =   2460
  262.          Left            =   450
  263.          Locked          =   -1  'True
  264.          MultiLine       =   -1  'True
  265.          ScrollBars      =   3  'Both
  266.          TabIndex        =   23
  267.          Top             =   1890
  268.          Width           =   2535
  269.       End
  270.       Begin VB.CommandButton cmdApply 
  271.          Caption         =   "Apply Above Settings"
  272.          Height          =   420
  273.          Left            =   -74310
  274.          TabIndex        =   11
  275.          ToolTipText     =   "Select PNG File"
  276.          Top             =   3375
  277.          Width           =   2070
  278.       End
  279.       Begin VB.CheckBox chkRatio 
  280.          Caption         =   "Lock Ratio"
  281.          Height          =   345
  282.          Left            =   -74025
  283.          TabIndex        =   10
  284.          Top             =   2745
  285.          Value           =   1  'Checked
  286.          Width           =   1350
  287.       End
  288.       Begin VB.CheckBox chkScale 
  289.          Caption         =   "Reset to 0,0 coordinates && 100% scale for each newly loaded PNG"
  290.          Height          =   810
  291.          Left            =   -74070
  292.          TabIndex        =   7
  293.          Top             =   1140
  294.          Value           =   1  'Checked
  295.          Width           =   1740
  296.       End
  297.       Begin VB.TextBox txtScale 
  298.          Alignment       =   2  'Center
  299.          Height          =   285
  300.          Index           =   0
  301.          Left            =   -74025
  302.          TabIndex        =   8
  303.          Text            =   "100"
  304.          Top             =   2385
  305.          Width           =   645
  306.       End
  307.       Begin VB.TextBox txtScale 
  308.          Alignment       =   2  'Center
  309.          Height          =   285
  310.          Index           =   1
  311.          Left            =   -73290
  312.          TabIndex        =   9
  313.          Text            =   "100"
  314.          Top             =   2385
  315.          Width           =   645
  316.       End
  317.       Begin VB.TextBox txtImgXY 
  318.          Alignment       =   2  'Center
  319.          Height          =   285
  320.          Index           =   0
  321.          Left            =   -73965
  322.          MaxLength       =   4
  323.          TabIndex        =   5
  324.          Text            =   "0"
  325.          Top             =   675
  326.          Width           =   645
  327.       End
  328.       Begin VB.TextBox txtImgXY 
  329.          Alignment       =   2  'Center
  330.          Height          =   285
  331.          Index           =   1
  332.          Left            =   -73230
  333.          MaxLength       =   4
  334.          TabIndex        =   6
  335.          Text            =   "0"
  336.          Top             =   660
  337.          Width           =   645
  338.       End
  339.       Begin VB.CheckBox chkAutoErase 
  340.          Caption         =   "Always Erase Canvas before Loading new PNG File"
  341.          Height          =   495
  342.          Left            =   -74490
  343.          TabIndex        =   2
  344.          Top             =   810
  345.          Value           =   1  'Checked
  346.          Width           =   2535
  347.       End
  348.       Begin VB.CheckBox chkAlphaBlend 
  349.          Caption         =   "Alpha blend PNG over canvas using opacity of"
  350.          Height          =   495
  351.          Left            =   -74490
  352.          TabIndex        =   3
  353.          Top             =   3885
  354.          Width           =   2475
  355.       End
  356.       Begin VB.Label Label3 
  357.          Caption         =   "Tip:  Double click settings to reset to defaults"
  358.          Height          =   420
  359.          Index           =   3
  360.          Left            =   -74325
  361.          TabIndex        =   40
  362.          Top             =   4170
  363.          Width           =   2115
  364.       End
  365.       Begin VB.Label lblInfo 
  366.          Caption         =   "Type: "
  367.          Height          =   240
  368.          Index           =   4
  369.          Left            =   555
  370.          TabIndex        =   39
  371.          Tag             =   "Type: "
  372.          Top             =   1320
  373.          Width           =   2295
  374.       End
  375.       Begin VB.Label Label3 
  376.          Caption         =   "How is Interlacing handled. Progressive display will be"
  377.          Height          =   435
  378.          Index           =   2
  379.          Left            =   -74490
  380.          TabIndex        =   38
  381.          Top             =   2565
  382.          Width           =   2160
  383.       End
  384.       Begin VB.Label Label3 
  385.          Caption         =   "How are background colors applied for images with transparencies"
  386.          Height          =   465
  387.          Index           =   1
  388.          Left            =   -74565
  389.          TabIndex        =   37
  390.          Top             =   120
  391.          Width           =   2580
  392.       End
  393.       Begin VB.Label Label3 
  394.          Caption         =   "Other Information within PNG"
  395.          Height          =   195
  396.          Index           =   0
  397.          Left            =   495
  398.          TabIndex        =   24
  399.          Top             =   1665
  400.          Width           =   2460
  401.       End
  402.       Begin VB.Label lblInfo 
  403.          Caption         =   "Interlaced: "
  404.          Height          =   240
  405.          Index           =   3
  406.          Left            =   555
  407.          TabIndex        =   22
  408.          Tag             =   "Interlaced: "
  409.          Top             =   1035
  410.          Width           =   2295
  411.       End
  412.       Begin VB.Label lblInfo 
  413.          Caption         =   "Bit Depth:"
  414.          Height          =   240
  415.          Index           =   2
  416.          Left            =   555
  417.          TabIndex        =   21
  418.          Tag             =   "Bit Depth: "
  419.          Top             =   750
  420.          Width           =   2295
  421.       End
  422.       Begin VB.Label lblInfo 
  423.          Caption         =   "Last Modified: "
  424.          Height          =   240
  425.          Index           =   1
  426.          Left            =   555
  427.          TabIndex        =   20
  428.          Tag             =   "Last Modified: "
  429.          Top             =   465
  430.          Width           =   2295
  431.       End
  432.       Begin VB.Label lblInfo 
  433.          Caption         =   "Size: "
  434.          Height          =   240
  435.          Index           =   0
  436.          Left            =   555
  437.          TabIndex        =   19
  438.          Tag             =   "Size: "
  439.          Top             =   195
  440.          Width           =   2295
  441.       End
  442.       Begin VB.Label Label2 
  443.          Alignment       =   2  'Center
  444.          Caption         =   "CANVAS CLEARING ACTIONS"
  445.          BeginProperty Font 
  446.             Name            =   "Tahoma"
  447.             Size            =   8.25
  448.             Charset         =   0
  449.             Weight          =   400
  450.             Underline       =   -1  'True
  451.             Italic          =   0   'False
  452.             Strikethrough   =   0   'False
  453.          EndProperty
  454.          ForeColor       =   &H8000000D&
  455.          Height          =   255
  456.          Left            =   -74520
  457.          TabIndex        =   18
  458.          Top             =   405
  459.          Width           =   2475
  460.       End
  461.       Begin VB.Label Label1 
  462.          AutoSize        =   -1  'True
  463.          BackStyle       =   0  'Transparent
  464.          Caption         =   "Scale W / H %"
  465.          Height          =   195
  466.          Index           =   1
  467.          Left            =   -73890
  468.          TabIndex        =   17
  469.          Top             =   2055
  470.          Width           =   1065
  471.       End
  472.       Begin VB.Label Label1 
  473.          AutoSize        =   -1  'True
  474.          BackStyle       =   0  'Transparent
  475.          Caption         =   "Image Left / Top"
  476.          Height          =   195
  477.          Index           =   0
  478.          Left            =   -73935
  479.          TabIndex        =   16
  480.          Top             =   330
  481.          Width           =   1200
  482.       End
  483.       Begin VB.Label lblBkg 
  484.          Alignment       =   2  'Center
  485.          Appearance      =   0  'Flat
  486.          BackColor       =   &H80000018&
  487.          BorderStyle     =   1  'Fixed Single
  488.          Caption         =   "Click to Clear the Canvas"
  489.          ForeColor       =   &H000000C0&
  490.          Height          =   300
  491.          Index           =   3
  492.          Left            =   -74565
  493.          TabIndex        =   15
  494.          Top             =   3285
  495.          Width           =   2565
  496.       End
  497.       Begin VB.Label lblBkg 
  498.          Alignment       =   2  'Center
  499.          Appearance      =   0  'Flat
  500.          BackColor       =   &H80000018&
  501.          BorderStyle     =   1  'Fixed Single
  502.          Caption         =   "Click to Remove Bkg Image"
  503.          ForeColor       =   &H000000C0&
  504.          Height          =   300
  505.          Index           =   2
  506.          Left            =   -74565
  507.          TabIndex        =   14
  508.          Top             =   2655
  509.          Width           =   2565
  510.       End
  511.       Begin VB.Label lblBkg 
  512.          Alignment       =   2  'Center
  513.          Appearance      =   0  'Flat
  514.          BackColor       =   &H80000018&
  515.          BorderStyle     =   1  'Fixed Single
  516.          Caption         =   "Click to Change Bkg Image"
  517.          ForeColor       =   &H00C00000&
  518.          Height          =   300
  519.          Index           =   1
  520.          Left            =   -74565
  521.          TabIndex        =   13
  522.          Top             =   2055
  523.          Width           =   2565
  524.       End
  525.       Begin VB.Label lblBkg 
  526.          Alignment       =   2  'Center
  527.          Appearance      =   0  'Flat
  528.          BackColor       =   &H80000018&
  529.          BorderStyle     =   1  'Fixed Single
  530.          Caption         =   "Click to Change Background Color"
  531.          ForeColor       =   &H00C00000&
  532.          Height          =   300
  533.          Index           =   0
  534.          Left            =   -74565
  535.          TabIndex        =   12
  536.          Top             =   1500
  537.          Width           =   2565
  538.       End
  539.    End
  540.    Begin VB.CommandButton cmdOpen 
  541.       Caption         =   "Load PNG Image"
  542.       Height          =   315
  543.       Left            =   60
  544.       TabIndex        =   0
  545.       ToolTipText     =   "Select PNG File"
  546.       Top             =   45
  547.       Width           =   3060
  548.    End
  549.    Begin MSComDlg.CommonDialog CommonDialog1 
  550.       Left            =   1155
  551.       Top             =   4470
  552.       _ExtentX        =   847
  553.       _ExtentY        =   847
  554.       _Version        =   393216
  555.    End
  556.    Begin VB.Label lblPBar 
  557.       Appearance      =   0  'Flat
  558.       BackColor       =   &H0024CACE&
  559.       BorderStyle     =   1  'Fixed Single
  560.       ForeColor       =   &H80000008&
  561.       Height          =   210
  562.       Left            =   60
  563.       TabIndex        =   43
  564.       Tag             =   "3045"
  565.       Top             =   5115
  566.       Visible         =   0   'False
  567.       Width           =   3045
  568.    End
  569.    Begin VB.Label lblInfo 
  570.       Caption         =   "Processing Time:"
  571.       Height          =   225
  572.       Index           =   5
  573.       Left            =   330
  574.       TabIndex        =   44
  575.       Tag             =   "Processing Time: "
  576.       Top             =   5115
  577.       Width           =   2760
  578.    End
  579. End
  580. Attribute VB_Name = "frmPNGmenu"
  581. Attribute VB_GlobalNameSpace = False
  582. Attribute VB_Creatable = False
  583. Attribute VB_PredeclaredId = True
  584. Attribute VB_Exposed = False
  585. Option Explicit
  586. ' For those that know my stuff, I generally add a ton of comments.
  587. ' This is for 3 main reasons:
  588. '   1) If this stuff is new to you, hopefully it doubles as a teaching aid
  589. '   2) If you understand it better, then you might be apt to recommend improvements
  590. '   3) So I know what the heck I was thinking when I revisit this in a year or so :)
  591.  
  592. ' Used to close Owner form when owned form is closed
  593.     Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  594.     Private Const WM_CLOSE As Long = &H10
  595.  
  596. ' used to create offscreen bitmap
  597.     Private Declare Function CreateCompatibleBitmap Lib "gdi32.dll" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
  598.     Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hDC As Long) As Long
  599.     Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hDC As Long, ByVal hObject As Long) As Long
  600.     Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
  601.     Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hDC As Long) As Long
  602.     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
  603.     Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As Long, ByVal hDC As Long) As Long
  604.     Private Declare Function GetGDIObject Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long
  605.     Private Type BITMAP
  606.         bmType As Long
  607.         bmWidth As Long
  608.         bmHeight As Long
  609.         bmWidthBytes As Long
  610.         bmPlanes As Integer
  611.         bmBitsPixel As Integer
  612.         bmBits As Long
  613.     End Type
  614.     Private hOldBmp As Long
  615.     Private hBmp As Long
  616.     Private tDC As Long
  617.  
  618. ' used for simple timing
  619.     Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
  620.     Private compileTipShown As Boolean
  621.  
  622. ' The routines, when compiled are fast, however, when using progressive display
  623. ' and also using a custom progress meter, the difference can be >100 ms depending
  624. ' on what code you are processing in the class's Progress event. So we'll
  625. ' turn off custom progress meter when progressive display is being used.
  626. Private bUseCustomProgressMeter As Boolean
  627.  
  628. ' the class has an option to CRC check each block/chunk of data received from the
  629. ' PNG file. Though this is optional, it is recommended. To make the class relatively
  630. ' safe from crashing on corrupted PNG data, On Error statements & hard-coded CRC
  631. ' checks on critical chunks are used. The following option is for use on
  632. ' non-critical chunks that do not prevent the image from being displayed.
  633. ' For example, the "last modified timestamp" chunk
  634. Private Const ValidateNonCriticalData As Boolean = True
  635.  
  636. ' the stdPNG class has optional feedback/events
  637. ' If feedback and progressive display are not wanted then,
  638. ' do not declare using the WithEvents keyword
  639. ' i.e.:  Private myPNG As StdPNG
  640.  
  641. ' Following are the 2 Events provided with the class
  642. Private WithEvents myPNG  As StdPNG
  643. Attribute myPNG.VB_VarHelpID = -1
  644.  
  645. Private Sub myPNG_ProgessiveDisplay(ByVal Width As Long, ByVal Height As Long, _
  646.                     destinationDC As Long, destinationHwnd As Long, _
  647.                     ByVal WinBkgColor As Long, ByVal AlphaPng As Boolean, _
  648.                     X As Long, Y As Long, ByVal IsInterlaced As Boolean, _
  649.                     ByVal useProgression As Boolean)
  650.     ' ^^ Width & Height are the true PNG sizes in pixels
  651.     ' ^^ destinationDC, destinationHwnd must be set to use progressive display
  652.     ' ^^ WinBkgColor is the suggested DC backcolor for the PNG
  653.     ' ^^ AlphaPng is True if the PNG uses any transparencies
  654.     ' ^^ X,Y are set to where progressively displayed PNG should be drawn at
  655.     ' ^^ IsInterlaced is True only if the image is encoded as progressively displayed
  656.     ' ^^ useProgression is a suggestion only. It will be True under the following cases
  657.     '       isInterlaced = True
  658.     '       isInterlaced = False and Width*Height> (ScreenWidth*ScreenHeight)\3
  659.     
  660.     
  661.     ' if you want to use progressive display, you must reply to this event.
  662.     ' Even if the PNG is not encoded with interlacing, simply passing
  663.     ' a valid hDC and hWnd value back to this event, the non-interlaced
  664.     ' PNG will be displayed using a scanner-type progressive display.
  665.     
  666.     ' Progressively displayed images cannot be performed if you want to
  667.     ' simultaneously stretch the image; therefore, there are no options to
  668.     ' specify a blt width/height.
  669.     
  670.     ' This is also the one area where you should check and modify any PNG
  671.     ' properties you want to possibly change (i.e., palette, progressive display mode)
  672.     
  673.     ' NOTE: This event will not be fired if you opted to
  674.     ' set class's ProgressiveDisplay property to pngNeverProgressive
  675.     
  676.     bUseCustomProgressMeter = True
  677.     lblPBar.Visible = True
  678.     
  679.     ' progressive display is not available when stretching image
  680.     ' so we will use our own progress meter
  681.     If Val(txtScale(0)) <> 100 Then Exit Sub
  682.     If Val(txtScale(1)) <> 100 Then Exit Sub
  683.     
  684.     ' basically, don't show a progress meter if we are going to use
  685.     ' progressive display as that, in itself, acts as a progress meter
  686.     If (IsInterlaced = False And chkIL = 1) Or useProgression = True Then
  687.         ' user wants to always display non-interlaced images w/scanner effect
  688.         ' or it is suggested to use progression. Note that if the option to
  689.         ' never use progressive display was set, we wouldn't get this event
  690.         bUseCustomProgressMeter = False
  691.         destinationDC = Form1.hDC
  692.         destinationHwnd = Form1.hwnd
  693.         X = Val(txtImgXY(0))
  694.         Y = Val(txtImgXY(1))
  695.         
  696.         lblPBar.Visible = False
  697.     End If
  698. End Sub
  699. Private Sub myPNG_Progress(ByVal Percentage As Long)
  700.  
  701.     ' Whether or not you want to display a progress bar is up to you
  702.     ' However, displaying a progress bar while also allowing progressive
  703.     ' display and the image is interlaced, will slow down the routines
  704.     ' just a bit while this event is being called.
  705.  
  706.     
  707.     ' Percentage is in whole numbers; Percentage/100 for decimals
  708.     If bUseCustomProgressMeter Then
  709.         If Percentage = 100 Then
  710.             lblPBar.Visible = False
  711.             lblPBar.Width = 0
  712.         Else
  713.             lblPBar.Width = Val(lblPBar.Tag) * (Percentage / 100)
  714.         End If
  715.         lblPBar.Refresh
  716.     End If
  717.  
  718. End Sub
  719.  
  720.  
  721. Private Sub cmdApply_Click()
  722.  
  723.     ' modify last drawn PNG, per user request
  724.     If myPNG Is Nothing Then Exit Sub
  725.     Dim X As Long, Y As Long, cx As Long, cy As Long
  726.     
  727.     X = Val(txtImgXY(0)): Y = Val(txtImgXY(1))
  728.     cx = (Val(txtScale(0)) / 100) * myPNG.Width
  729.     cy = (Val(txtScale(1)) / 100) * myPNG.Height
  730.     
  731.     RefreshCanvas
  732.     myPNG.Paint Form1.hDC, X, Y, cx, cy, , , , myPNG.Width, myPNG.Height
  733.     Form1.Refresh
  734.     
  735. End Sub
  736.  
  737. Private Sub cmdOpen_Click()
  738.  
  739.     With CommonDialog1  ' show file select dialog window
  740.         .Flags = cdlOFNFileMustExist Or cdlOFNExplorer
  741.         .CancelError = True
  742.         .Filter = "PNG Files|*.png"
  743.         .FilterIndex = 0
  744.         .DialogTitle = "Select PNG File to Display"
  745.     End With
  746.     On Error GoTo UserAbort
  747.     
  748.     CommonDialog1.ShowOpen
  749.     Me.Refresh
  750.     DoEvents ' refresh our form
  751.     LoadPNGfile CommonDialog1.Filename, CommonDialog1.FileTitle
  752.     If myPNG.Handle = 0 Then
  753.         ' whatever you want to do. Png file did not load
  754.     End If
  755.     
  756. UserAbort:
  757. 'If Err Then MsgBox Err.Description
  758. 'Resume
  759. End Sub
  760.  
  761. Private Sub LoadPNGfile(sFileName As String, displayName As String)
  762.  
  763.     Dim lRtn As Long, dRtn As Double, dDate As Date
  764.     Dim dChromo() As Double, lArray() As Long
  765.     Dim myTimer As Long
  766.     
  767.     SetUserOptions displayName
  768.     
  769.     If myPNG Is Nothing Then Set myPNG = New StdPNG
  770.     
  771.     ' ok, let's start the process
  772.     myTimer = GetTickCount
  773.     If chkAlphaBlend Then lRtn = Val(txtAlphaBlend) Else lRtn = 255
  774.     If myPNG.LoadFile(sFileName, ValidateNonCriticalData, , CByte(lRtn)) Then
  775.     '^^ Parameter info:
  776.     ' 1st :: the full path & filename of the PNG to load/display
  777.     ' 2nd :: True to validate all PNG data, else only critical data is validated
  778.     ' 3rd :: True will force PNG to 32bpp BMP. Needed for alphablending if desired
  779.     ' 4th :: from 0-255 and will blend the final result into a DC when
  780.     '        progressively displaying PNG. Any value < 255 will force a 32bpp BMP
  781.     
  782.         ' Display PNG properties
  783.         myTimer = GetTickCount() - myTimer
  784.         If myTimer < 50 Then '
  785.             ' GetTickcount isn't very accurate at small intervals
  786.             lblInfo(5).Caption = lblInfo(5).Tag & "less than 50 ms"
  787.         Else
  788.             lblInfo(5).Caption = lblInfo(5).Tag & myTimer & " ms"
  789.         End If
  790.     
  791.         lblInfo(0).Caption = lblInfo(0).Tag & myPNG.Width & " x " & myPNG.Height
  792.         
  793.         dRtn = myPNG.LastModified
  794.         
  795.         If dRtn = 0 Then
  796.             lblInfo(1).Caption = lblInfo(1).Tag & "Not provided"
  797.         Else
  798.             lblInfo(1).Caption = lblInfo(1).Tag & Format(dRtn, "Short Date")
  799.         End If
  800.             
  801.         lblInfo(2).Caption = lblInfo(2).Tag & myPNG.BitCount_PNG & ", Converted: " & myPNG.BitCount_BMP
  802.         
  803.         lblInfo(3).Caption = lblInfo(3).Tag & Format(myPNG.IsInterlaced, "Yes/No")
  804.         
  805.         Select Case myPNG.ColorType
  806.         Case 0: ' grayscale
  807.             lblInfo(4).Caption = lblInfo(4).Tag & "Gray Scaled"
  808.         Case 2: ' true color
  809.             lblInfo(4).Caption = lblInfo(4).Tag & "True Color"
  810.         Case 3: ' paletted
  811.             lblInfo(4).Caption = lblInfo(4).Tag & "Paletted"
  812.         Case 4: ' grayscale with transparency
  813.             lblInfo(4).Caption = lblInfo(4).Tag & "Gray Scale w/Alpha"
  814.         Case 6: ' true color with transparency
  815.             lblInfo(4).Caption = lblInfo(4).Tag & "True Color w/Alpha"
  816.         End Select
  817.         
  818.         Text1.Text = myPNG.Comments("No embedded comments")
  819.         dRtn = myPNG.GammaCorrection
  820.         If dRtn Then
  821.             lRtn = Int(1 / dRtn)
  822.             dRtn = Int(1 / dRtn * 10) / 10
  823.             Text1.Text = Text1.Text & vbCrLf & "Gamma Correction: " & FormatNumber(dRtn, 1)
  824.         End If
  825.         
  826.         dChromo() = myPNG.Chromaticity()
  827.         If UBound(dChromo) > -1 Then
  828.             Text1.Text = Text1.Text & vbCrLf & "Chromaticity:" & vbCrLf & "     WhiteX " & FormatNumber(dChromo(0), 2) & _
  829.                 vbCrLf & "     WhiteY " & FormatNumber(dChromo(1), 2) & _
  830.                 vbCrLf & "     RedX " & FormatNumber(dChromo(2), 2) & _
  831.                 vbCrLf & "     RedY " & FormatNumber(dChromo(3), 2) & _
  832.                 vbCrLf & "     GreenX " & FormatNumber(dChromo(4), 2) & _
  833.                 vbCrLf & "     GreenY " & FormatNumber(dChromo(5), 2) & _
  834.                 vbCrLf & "     BlueX " & FormatNumber(dChromo(6), 2) & _
  835.                 vbCrLf & "     BlueY " & FormatNumber(dChromo(7), 2)
  836.         End If
  837.         lArray() = myPNG.AspectRatio()
  838.         If UBound(lArray) > -1 Then
  839.             '.0254 is the offical png meter to inch conversion ratio
  840.             If lArray(2) = 1 Then ' pixel size is meters to inches
  841.                 Text1.Text = Text1.Text & vbCrLf & "Aspect Ratio:" & _
  842.                     vbCrLf & "  Logical X = " & Int(0.0254 * lArray(0)) & _
  843.                     vbCrLf & "  Logical Y = " & Int(0.0254 * lArray(1))
  844.             Else
  845.                 Text1.Text = Text1.Text & vbCrLf & "Aspect Ratio:" & _
  846.                     vbCrLf & "  Aspect Ratio: " & lArray(0) & ":" & lArray(1)
  847.             End If
  848.         End If
  849.         lArray() = myPNG.Offsets()
  850.         If UBound(lArray) > -1 Then
  851.             Text1.Text = Text1.Text & vbCrLf & "Page Offsets:" & _
  852.                 vbCrLf & "  X = " & lArray(0) & " " & Choose(lArray(2) + 1, "Pixels", "Microns") & _
  853.                 vbCrLf & "  Y = " & lArray(1) & " " & Choose(lArray(2) + 1, "Pixels", "Microns")
  854.         End If
  855.         If myPNG.StdRGB Then
  856.             Text1.Text = Text1.Text & vbCrLf & "Standard RGB color space:" & vbCrLf & _
  857.                 "  :: " & Choose(myPNG.StdRGB, "Perceptual", "Relative Colorimetric", "Saturation", "Absolute Colorimetric")
  858.         End If
  859.         
  860.         If bUseCustomProgressMeter = True Then
  861.             ' we were not progressively displaying, so paint the PNG now
  862.             If chkAlphaBlend Then
  863.                 myPNG.Paint Form1.hDC, Val(txtImgXY(0)), Val(txtImgXY(1)), _
  864.                     myPNG.Width * (Val(txtScale(0)) / 100), myPNG.Height * (Val(txtScale(1)) / 100), , , , , , Val(txtAlphaBlend)
  865.             Else
  866.                 myPNG.Paint Form1.hDC, Val(txtImgXY(0)), Val(txtImgXY(1)), _
  867.                     myPNG.Width * (Val(txtScale(0)) / 100), myPNG.Height * (Val(txtScale(1)) / 100)
  868.             End If
  869.             Form1.Refresh
  870.         End If
  871.         
  872.         If Not compileTipShown Then
  873.             compileTipShown = True
  874.             On Error Resume Next
  875.             Debug.Print 1 / 0
  876.             If Err Then
  877.                 MsgBox "Compiling a copy of this application will result in dramatic speed increases", vbInformation + vbOKOnly
  878.             End If
  879.         End If
  880.         
  881.     Else
  882.         ' error occurred... Reset form
  883.         For lRtn = 0 To lblInfo.UBound
  884.             lblInfo(lRtn).Caption = lblInfo(lRtn).Tag
  885.         Next
  886.         Text1 = ""
  887.         
  888.     End If
  889.     
  890.     If chkShowInfo Then SSTab1.Tab = 3 ' show the PNG Info tab
  891.     
  892. End Sub
  893.  
  894. Private Sub cmdWrite_Click()
  895.     MsgBox "Not yet implemented", vbInformation + vbOKOnly
  896. End Sub
  897.  
  898. Private Sub Form_Load()
  899.     Me.Move Form1.Left - Me.Width, (Screen.Height - Me.Height) \ 2
  900.     lblPBar.Tag = lblPBar.Width
  901. End Sub
  902.  
  903. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  904.     ' this is a owned form which stays on top of its owner (Form1).
  905.     ' So if I want the owner to close too,
  906.     ' post it a message, otherwise, we go into an infinite loop
  907.     If UnloadMode = 0 Then PostMessage Form1.hwnd, WM_CLOSE, 0, 0
  908.     ' When owner is closing this form closes automatically too. The UnloadMode will = 5
  909. End Sub
  910.  
  911. Private Sub Form_Unload(Cancel As Integer)
  912.  
  913.     EraseOffscreenBitmap
  914.     If Not myPNG Is Nothing Then Set myPNG = Nothing
  915.  
  916. End Sub
  917.  
  918. Private Sub SetTextBoxFocus(txtObj As TextBox)
  919.     With txtObj
  920.         .SelStart = 0
  921.         .SelLength = Len(.Text)
  922.     End With
  923. End Sub
  924.  
  925. Private Sub lblBkg_Click(Index As Integer)
  926.  
  927.     EraseOffscreenBitmap
  928.     Select Case Index
  929.     Case 0 ' back color
  930.         With CommonDialog1
  931.             .Flags = cdlCCFullOpen
  932.             .CancelError = True
  933.         End With
  934.         On Error GoTo UserAbort
  935.         CommonDialog1.ShowColor
  936.         Form1.BackColor = CommonDialog1.Color
  937.         
  938.     Case 1 ' back image
  939.         With CommonDialog1
  940.             .Flags = cdlOFNFileMustExist
  941.             .Filter = "Bitmaps|*.bmp|JPeg|*.jpg;*.jpeg|GIFs|*.gif"
  942.             .FilterIndex = 0
  943.             .Filename = ""
  944.             .DialogTitle = "Select Canvas Background Image"
  945.             .CancelError = True
  946.         End With
  947.         On Error GoTo UserAbort
  948.         CommonDialog1.ShowOpen
  949.         Set Form1.Picture = LoadPicture(CommonDialog1.Filename)
  950.         
  951.     Case 2 ' remove back image
  952.         Set Form1.Picture = LoadPicture("")
  953.         
  954.     Case 3 ' clear
  955.         Form1.Cls
  956.     End Select
  957.  
  958.     If Not myPNG Is Nothing Then
  959.         If Index < 3 Then Call cmdApply_Click
  960.     End If
  961.  
  962. UserAbort:
  963. End Sub
  964.  
  965. Private Sub lblBkgColor_Click()
  966.     Call lblShowColorDlg_Click
  967. End Sub
  968.  
  969. Private Sub lblShowColorDlg_Click()
  970.     With CommonDialog1
  971.         .Flags = cdlCCFullOpen
  972.         .CancelError = True
  973.     End With
  974.     On Error GoTo UserAbort
  975.     CommonDialog1.ShowColor
  976.     lblBkgColor.BackColor = CommonDialog1.Color
  977.     
  978. UserAbort:
  979. End Sub
  980.  
  981. Private Sub optIL_Click(Index As Integer)
  982.     If myPNG Is Nothing Then Set myPNG = New StdPNG
  983.     Select Case Index
  984.     Case 0: ' Default
  985.         myPNG.ProgressiveDisplay = pngAuto
  986.     Case 1: ' Never use it
  987.         myPNG.ProgressiveDisplay = pngNeverProgressive
  988.         ' can't have scanner-effect for non-interlaced either then
  989.         chkIL = 0
  990.     Case 2: ' Fade-In for non-transparent interlaced images
  991.         myPNG.ProgressiveDisplay = pngFadeIn
  992.     End Select
  993.     If chkIL = 1 Then myPNG.ProgressiveDisplay = myPNG.ProgressiveDisplay Or pngScanner
  994. End Sub
  995.  
  996. Private Sub optTrans_Click(Index As Integer)
  997.     
  998. ' Things to think about when replacing transparency with solid/opaque colors:
  999. ' 1. The converted DIB will be smaller
  1000. ' 2. All transparency information is permanently lost within the DIB; the PNG
  1001. '    is untouched. The loss is due to a DIB bit depth < 32bpp. If you wish to
  1002. '    keep transparency but want a different bkg color, load the PNG using
  1003. '    full transparency, but don't display it progressively. Next fill your
  1004. '    DC with the bkg color and simply stdPNG.Paint the DIB over that DC.
  1005. '    The .Paint method accepts an alphablend value so you can blend it to a bkg too
  1006. ' 3. Any 32bpp DIB cannot be saved 100% lossless to a PNG format. This is for 2
  1007. '    main reasons. First: 32bpp images have premultiplied RGB values and calculating
  1008. '    the non-premultiplied values can be off by 1 due to rounding errors. And the
  1009. '    2nd reason: Pre-multiplied full transparent pixels are RGB(0,0,0) regardless
  1010. '    of its original color; therefore, getting the original transparent color back
  1011. '    is impossible. This would generally not be too big of an issue, but
  1012. '    if you want that color back, the DIB would have to be processed pixel by pixel
  1013. '    and the color would have to manually added.
  1014.     
  1015.     If myPNG Is Nothing Then Set myPNG = New StdPNG
  1016.     
  1017.     Select Case Index
  1018.         Case 0: myPNG.TransparentStyle = alphaTransparent
  1019.                 '^^ alpha is alpha
  1020.         Case 1: myPNG.TransparentStyle = alphaPNGwindowBkg  ' use default bkg
  1021.                 '^^ if not provided by png, it will be white
  1022.                 '   Maybe best option for color types 4,6
  1023.         Case 2: myPNG.TransparentStyle = lblBkgColor.BackColor
  1024.                 '^^ supply own bkg
  1025.         Case 3: myPNG.TransparentStyle = alphaNoBkgNoAlpha
  1026.                 '^^ worse possible choice, shows alpha as non-alpha & those colors
  1027.                 '   can be any color in the world. The image may really look bad IMO
  1028.         Case 4: myPNG.TransparentStyle = alphaTransColorBkg
  1029.         '^^ this is usually the best choice for converting alpha to non-alpha
  1030.         '   When the PNG color type is 0,2,3. Color types 4,6 have embeeded
  1031.         '   alpha values and those generally look better by selecting the
  1032.         '   suggest window bkg color or providing your own if no suggested color provided
  1033.     End Select
  1034. End Sub
  1035.  
  1036. Private Sub txtAlphaBlend_GotFocus()
  1037.     SetTextBoxFocus txtAlphaBlend
  1038. End Sub
  1039.  
  1040. Private Sub txtAlphaBlend_Validate(Cancel As Boolean)
  1041.     Select Case Val(txtAlphaBlend)
  1042.         Case Is < 0: txtAlphaBlend = 0
  1043.         Case Is > 255: txtAlphaBlend = 255
  1044.         Case Else: txtAlphaBlend = Int(txtAlphaBlend)
  1045.     End Select
  1046. End Sub
  1047.  
  1048. Private Sub txtImgXY_DblClick(Index As Integer)
  1049.     ' just reset the X,Y coordinates to 0,0 when double clicked
  1050.     txtImgXY(Index) = 0
  1051.     If chkRatio Then txtImgXY(Abs(Index - 1)) = 0
  1052. End Sub
  1053.  
  1054. Private Sub txtImgXY_GotFocus(Index As Integer)
  1055.     SetTextBoxFocus txtImgXY(Index)
  1056. End Sub
  1057.  
  1058. Private Sub txtImgXY_Validate(Index As Integer, Cancel As Boolean)
  1059.  
  1060.     Dim maxCX As Long, maxCY As Long
  1061.     maxCX = Screen.Width \ Screen.TwipsPerPixelX
  1062.     maxCY = Screen.Height \ Screen.TwipsPerPixelY
  1063.     
  1064.     If Index = 0 Then
  1065.         If Val(txtImgXY(Index)) > maxCX Then
  1066.             txtImgXY(Index) = maxCX
  1067.         ElseIf Val(txtImgXY(Index)) < -maxCX Then
  1068.             txtImgXY(Index) = -maxCX
  1069.         End If
  1070.     Else
  1071.         If Val(txtImgXY(Index)) > maxCY Then
  1072.             txtImgXY(Index) = maxCY
  1073.         ElseIf Val(txtImgXY(Index)) < -maxCY Then
  1074.             txtImgXY(Index) = -maxCY
  1075.         End If
  1076.     End If
  1077. End Sub
  1078.  
  1079. Private Sub txtScale_Change(Index As Integer)
  1080.     If chkRatio Then txtScale(Abs(Index - 1)).Text = txtScale(Index)
  1081. End Sub
  1082.  
  1083. Private Sub txtScale_DblClick(Index As Integer)
  1084.     ' reset the scaling to 100% when double clicked
  1085.     txtScale(Index) = 100
  1086.     If chkRatio Then txtScale(Abs(Index - 1)) = 100
  1087.  
  1088. End Sub
  1089.  
  1090. Private Sub txtScale_GotFocus(Index As Integer)
  1091.     SetTextBoxFocus txtScale(Index)
  1092. End Sub
  1093.  
  1094. Private Sub txtScale_Validate(Index As Integer, Cancel As Boolean)
  1095.     If Index = 0 Then
  1096.         If Val(txtScale(Index)) > 500 Then txtScale(Index) = 500
  1097.     Else
  1098.         If Val(txtScale(Index)) > 500 Then txtScale(Index) = 500
  1099.     End If
  1100.     If Val(txtScale(Index)) < 10 Then txtScale(Index) = 10
  1101. End Sub
  1102.  
  1103. Private Sub chkIL_Click()
  1104.     If chkIL = 1 Then
  1105.         ' if wanting non-interlaced to have the interlaced scanner effect,
  1106.         ' then ensure the "Prevent Interlacing" option is not active
  1107.         If optIL(1) = True Then optIL(0) = True
  1108.     End If
  1109. End Sub
  1110.  
  1111. Private Sub RefreshCanvas()
  1112.     Form1.Cls
  1113.     If tDC Then
  1114.         Dim bmpInfo As BITMAP
  1115.         GetGDIObject hBmp, Len(bmpInfo), bmpInfo
  1116.         BitBlt Form1.hDC, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, tDC, 0, 0, vbSrcCopy
  1117.     End If
  1118.     Form1.Refresh
  1119. End Sub
  1120.  
  1121. Private Sub CreateScreenShot()
  1122.  
  1123.     Dim Wd As Long, Ht As Long
  1124.     
  1125.     If tDC = 0 Then
  1126.         tDC = CreateCompatibleDC(Me.hDC)
  1127.     Else
  1128.         DeleteObject SelectObject(tDC, hOldBmp)
  1129.     End If
  1130.     
  1131.     Wd = Form1.ScaleWidth \ Screen.TwipsPerPixelX
  1132.     Ht = Form1.ScaleHeight \ Screen.TwipsPerPixelY
  1133.     
  1134.     hBmp = CreateCompatibleBitmap(Me.hDC, Wd, Ht)
  1135.     ReleaseDC Me.hwnd, Me.hDC
  1136.     
  1137.     hOldBmp = SelectObject(tDC, hBmp)
  1138.     BitBlt tDC, 0, 0, Wd, Ht, Form1.hDC, 0, 0, vbSrcCopy
  1139.     
  1140. End Sub
  1141.  
  1142. Private Sub EraseOffscreenBitmap()
  1143.  
  1144.     If tDC Then
  1145.         DeleteObject SelectObject(tDC, hOldBmp)
  1146.         DeleteDC tDC
  1147.     End If
  1148.     tDC = 0
  1149.  
  1150. End Sub
  1151.  
  1152. Private Sub SetUserOptions(displayName As String)
  1153.  
  1154.     ' following is to set up the form & options based on the different
  1155.     ' option buttons/checkboxes, etc, that you may have been clicking on
  1156.     Form1.Caption = displayName
  1157.  
  1158.     If chkAutoErase = 0 Then
  1159.         CreateScreenShot
  1160.     Else
  1161.         EraseOffscreenBitmap
  1162.         Form1.Cls
  1163.         DoEvents
  1164.     End If
  1165.     If chkScale = 1 Then
  1166.         txtImgXY(0) = 0
  1167.         txtImgXY(1) = 0
  1168.         txtScale(0) = 100
  1169.         txtScale(1) = 100
  1170.     End If
  1171.     
  1172.     ' ensure any settings while PNG not active are accounted for
  1173.     Dim I As Integer
  1174.     For I = 0 To optIL.UBound
  1175.         If optIL(I) = True Then
  1176.             Call optIL_Click(I)
  1177.             Exit For
  1178.         End If
  1179.     Next
  1180.     For I = 0 To optTrans.UBound
  1181.         If optTrans(I) = True Then
  1182.             Call optTrans_Click(I)
  1183.             Exit For
  1184.         End If
  1185.     Next
  1186.     If optIL(1) = True Then ' prevent progressive display, use custom progress meter
  1187.         bUseCustomProgressMeter = True
  1188.         lblPBar.Visible = True
  1189.     End If
  1190.  
  1191. End Sub
  1192.