home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" Begin VB.Form frmPicText0 Caption = "Image Texter" ClientHeight = 6405 ClientLeft = 60 ClientTop = 630 ClientWidth = 11640 Icon = "pictext0.frx":0000 LinkTopic = "Form1" LockControls = -1 'True ScaleHeight = 427 ScaleMode = 3 'Pixel ScaleWidth = 776 Begin VB.Frame fraTextPanel Height = 1395 Left = 1650 TabIndex = 8 Top = 60 Width = 9015 Begin VB.TextBox txbWriteText Height = 360 Left = 120 TabIndex = 17 TabStop = 0 'False Text = "Type text here" Top = 930 Width = 7185 End Begin VB.Frame fraMainColor Height = 615 Left = 2820 TabIndex = 13 Top = 0 Width = 4485 Begin VB.PictureBox picTextColor Appearance = 0 'Flat BackColor = &H80000005& ForeColor = &H80000008& Height = 270 Left = 900 ScaleHeight = 240 ScaleWidth = 240 TabIndex = 15 TabStop = 0 'False Top = 210 Width = 270 End Begin VB.CommandButton cmdTextColor Height = 270 Left = 90 Picture = "pictext0.frx":030A Style = 1 'Graphical TabIndex = 14 TabStop = 0 'False ToolTipText = "Color dialog" Top = 210 Width = 270 End Begin VB.Image imgColorPicker Appearance = 0 'Flat BorderStyle = 1 'Fixed Single Height = 270 Left = 480 Picture = "pictext0.frx":064C ToolTipText = "Color picker (from image)" Top = 210 Width = 270 End Begin VB.Label lblTextColor Caption = "lblTextColor" Height = 255 Left = 1590 TabIndex = 16 Top = 240 Width = 2715 End End Begin VB.Frame frafont Height = 915 Index = 0 Left = 120 TabIndex = 9 Top = 0 Width = 2565 Begin VB.ComboBox cboFontName Appearance = 0 'Flat Height = 315 Left = 90 Sorted = -1 'True Style = 2 'Dropdown List TabIndex = 11 TabStop = 0 'False Top = 180 Width = 2385 End Begin VB.TextBox txtFontSize Height = 300 Left = 630 TabIndex = 10 TabStop = 0 'False Text = "24" Top = 540 Width = 375 End Begin VB.Label lblFontSize1 Caption = "Size" Height = 225 Left = 240 TabIndex = 12 Top = 600 Width = 375 End Begin VB.Image imgBold Appearance = 0 'Flat BorderStyle = 1 'Fixed Single Height = 270 Left = 1380 Picture = "pictext0.frx":0796 ToolTipText = "Bold" Top = 570 Width = 270 End Begin VB.Image imgItalic Appearance = 0 'Flat BorderStyle = 1 'Fixed Single Height = 270 Left = 1890 Picture = "pictext0.frx":08E0 ToolTipText = "Italic" Top = 570 Width = 270 End End Begin VB.Shape shpTextSample Height = 1245 Left = 7560 Top = 120 Width = 1335 End Begin VB.Label lblTextSample Appearance = 0 'Flat BackColor = &H80000005& Caption = "Aa" ForeColor = &H80000008& Height = 1185 Left = 7620 TabIndex = 18 Top = 150 Width = 1215 End End Begin VB.PictureBox picZ BackColor = &H00C0C0C0& Height = 4305 Left = 1650 ScaleHeight = 283 ScaleMode = 3 'Pixel ScaleWidth = 579 TabIndex = 2 Top = 1530 Width = 8745 Begin VB.PictureBox picDisp Appearance = 0 'Flat AutoRedraw = -1 'True AutoSize = -1 'True BackColor = &H80000005& ForeColor = &H80000008& Height = 4335 Left = 0 MouseIcon = "pictext0.frx":0A2A Picture = "pictext0.frx":0D34 ScaleHeight = 287 ScaleMode = 3 'Pixel ScaleWidth = 369 TabIndex = 7 Top = 0 Width = 5565 End Begin VB.PictureBox picAuto Appearance = 0 'Flat AutoRedraw = -1 'True AutoSize = -1 'True BackColor = &H00FFFFFF& ForeColor = &H80000008& Height = 675 Left = 870 ScaleHeight = 43 ScaleMode = 3 'Pixel ScaleWidth = 45 TabIndex = 22 Top = 1920 Visible = 0 'False Width = 705 End Begin VB.PictureBox picTemp Appearance = 0 'Flat AutoRedraw = -1 'True BackColor = &H80000005& ForeColor = &H80000008& Height = 645 Left = 810 MouseIcon = "pictext0.frx":4E7A2 ScaleHeight = 41 ScaleMode = 3 'Pixel ScaleWidth = 47 TabIndex = 21 Top = 1200 Visible = 0 'False Width = 735 End Begin VB.PictureBox picRegion Appearance = 0 'Flat AutoRedraw = -1 'True BackColor = &H80000005& ForeColor = &H80000008& Height = 615 Left = 3750 MouseIcon = "pictext0.frx":4EAAC ScaleHeight = 39 ScaleMode = 3 'Pixel ScaleWidth = 39 TabIndex = 4 Top = 1830 Visible = 0 'False Width = 615 End Begin VB.PictureBox picSnap Appearance = 0 'Flat AutoRedraw = -1 'True BackColor = &H00FFFFFF& ForeColor = &H80000008& Height = 1005 Left = 2700 MouseIcon = "pictext0.frx":4EDB6 ScaleHeight = 65 ScaleMode = 3 'Pixel ScaleWidth = 65 TabIndex = 6 Top = 480 Visible = 0 'False Width = 1005 End Begin VB.PictureBox picUndo Appearance = 0 'Flat AutoRedraw = -1 'True BackColor = &H00FFFFFF& ForeColor = &H80000008& Height = 615 Left = 660 MouseIcon = "pictext0.frx":4F0C0 ScaleHeight = 39 ScaleMode = 3 'Pixel ScaleWidth = 47 TabIndex = 5 Top = 570 Visible = 0 'False Width = 735 End Begin VB.PictureBox picMask Appearance = 0 'Flat AutoRedraw = -1 'True BackColor = &H00FFFFFF& ForeColor = &H00404040& Height = 615 Left = 2790 MouseIcon = "pictext0.frx":4F3CA ScaleHeight = 39 ScaleMode = 3 'Pixel ScaleWidth = 37 TabIndex = 3 Top = 1650 Visible = 0 'False Width = 585 End End Begin VB.VScrollBar VScroll1 Height = 4275 Left = 10410 TabIndex = 1 TabStop = 0 'False Top = 1530 Width = 255 End Begin VB.HScrollBar HScroll1 Height = 240 Left = 1650 TabIndex = 0 TabStop = 0 'False Top = 5850 Width = 8745 End Begin MSComDlg.CommonDialog CommonDialog1 Left = 360 Top = 5640 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin MSComctlLib.ImageList ImageList1 Left = 900 Top = 5580 _ExtentX = 1005 _ExtentY = 1005 BackColor = -2147483643 ImageWidth = 16 ImageHeight = 10 MaskColor = 12632256 _Version = 393216 BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} NumListImages = 4 BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "pictext0.frx":4F6D4 Key = "UpperLeft" EndProperty BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "pictext0.frx":4F8B0 Key = "UpperRight" EndProperty BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "pictext0.frx":4FA8C Key = "LowerLeft" EndProperty BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "pictext0.frx":4FC68 Key = "LowerRight" EndProperty EndProperty End Begin VB.Frame fraRotateAngle Height = 2295 Left = 30 TabIndex = 30 Top = 60 Width = 1575 Begin VB.ComboBox cboRotateAngle Height = 315 Left = 480 Style = 2 'Dropdown List TabIndex = 33 Top = 1530 Width = 735 End Begin VB.PictureBox picRotateAngleSampleBgd Appearance = 0 'Flat AutoRedraw = -1 'True BackColor = &H00FFFFFF& ForeColor = &H80000008& Height = 1245 Left = 180 ScaleHeight = 81 ScaleMode = 3 'Pixel ScaleWidth = 81 TabIndex = 32 Top = 150 Width = 1245 Begin VB.PictureBox picRotateAngleSample Appearance = 0 'Flat AutoRedraw = -1 'True BackColor = &H00C0C0C0& BorderStyle = 0 'None ForeColor = &H80000008& Height = 240 Left = 240 Picture = "pictext0.frx":4FE44 ScaleHeight = 16 ScaleMode = 3 'Pixel ScaleWidth = 52 TabIndex = 35 Top = 480 Visible = 0 'False Width = 780 End End Begin VB.HScrollBar HsbRotateAngle Height = 285 Left = 150 Max = 360 Min = -360 TabIndex = 31 Top = 1920 Width = 1335 End Begin VB.Label lblAnglePreset Caption = "At BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 210 TabIndex = 34 Top = 1560 Width = 1155 End End Begin VB.Frame fra1Color3D Caption = "1 Color 3D" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 3165 Left = 30 TabIndex = 24 Top = 2430 Width = 1575 Begin VB.ComboBox cboShadeThickness Height = 315 Left = 780 Style = 2 'Dropdown List TabIndex = 27 Top = 420 Width = 585 End Begin VB.CommandButton cmdCancel Caption = "Cancel" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 3 Left = 30 Style = 1 'Graphical TabIndex = 26 TabStop = 0 'False Top = 2640 Width = 1485 End Begin VB.CommandButton cmd1Color3DProceed Caption = "Proceed" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 555 Left = 30 Style = 1 'Graphical TabIndex = 25 TabStop = 0 'False Top = 2070 Width = 1485 End Begin MSComctlLib.ImageCombo icb1Color3D Height = 330 Left = 270 TabIndex = 28 TabStop = 0 'False Top = 1020 Width = 1065 _ExtentX = 1879 _ExtentY = 582 _Version = 393216 ForeColor = -2147483640 BackColor = -2147483643 Text = "icb1Color3D" End Begin VB.Label lblShadeThickness Caption = "Shade" Height = 225 Left = 210 TabIndex = 29 Top = 480 Width = 495 End End Begin VB.Frame fraRegion Height = 5535 Left = 90 TabIndex = 23 Top = 90 Width = 1515 Begin VB.Image imgRegion Appearance = 0 'Flat BorderStyle = 1 'Fixed Single Height = 390 Left = 570 Picture = "pictext0.frx":5097E ToolTipText = "Toggle drawing region (for Cut/Copy)" Top = 630 Width = 375 End End Begin VB.Label lblFileSpec Appearance = 0 'Flat BackColor = &H80000004& BorderStyle = 1 'Fixed Single Caption = "lblFileSpec" ForeColor = &H80000008& Height = 285 Left = 1650 TabIndex = 20 Top = 6120 Width = 8985 End Begin VB.Label lblImageSize Appearance = 0 'Flat BorderStyle = 1 'Fixed Single Caption = "W= H=" ForeColor = &H80000008& Height = 285 Left = 90 TabIndex = 19 Top = 6120 Width = 1425 End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuFileNew Caption = "&New" End Begin VB.Menu mnuFileOpen Caption = "&Open...." End Begin VB.Menu mnuFileSave Caption = "&Save...." End Begin VB.Menu mnuFileSep1 Caption = "-" End Begin VB.Menu mnuFileExit Caption = "E&xit" End End Begin VB.Menu mnuText Caption = "&Text" Begin VB.Menu mnuTextWrite Caption = "&Ordinary...." Enabled = 0 'False Index = 0 End Begin VB.Menu mnuTextWrite Caption = "&Hollow...." Enabled = 0 'False Index = 1 End Begin VB.Menu mnuTextWrite Caption = "Framed...." Enabled = 0 'False Index = 2 End Begin VB.Menu mnuTextWrite Caption = "&Shadowed...." Enabled = 0 'False Index = 3 End Begin VB.Menu mnuTextWrite Caption = "&1-color 3-D...." Index = 4 End Begin VB.Menu mnuTextWrite Caption = "&2-color 3-D" Enabled = 0 'False Index = 5 End Begin VB.Menu mnuTextWrite Caption = "E&mbossed..." Enabled = 0 'False Index = 6 End Begin VB.Menu mnuTextWrite Caption = "E&ngraved..." Enabled = 0 'False Index = 7 End Begin VB.Menu mnuTextWrite Caption = "&Gradient text...." Enabled = 0 'False Index = 8 End End Begin VB.Menu mnuTools Caption = "T&ools" Begin VB.Menu mnuToolsRegion Caption = "&Region" End End Begin VB.Menu mnuEdit Caption = "&Edit" Begin VB.Menu mnuEditUndo Caption = "&Undo" End Begin VB.Menu mnuEditSep1 Caption = "-" End Begin VB.Menu mnuEditCut Caption = "Cu&t" End Begin VB.Menu mnuEditCopy Caption = "&Copy" End Begin VB.Menu mnuEditPaste Caption = "&Paste" End Begin VB.Menu mnuEditPasteTransparent Caption = "Paste t&ransparent (top pixel)" End Begin VB.Menu mnuEditSep2 Caption = "-" End Begin VB.Menu mnuEditClearClipboard Caption = "C&lear Clipboard" End Begin VB.Menu mnuEditSep3 Caption = "-" End Begin VB.Menu mnuEditPasteFromFile Caption = "Paste from &file" End Begin VB.Menu mnuEditPasteFromFileTransparent Caption = "Paste from file tr&ansparent (top pixel)" End End Attribute VB_Name = "frmPicText0" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False ' PicText0.prg ' By Herman Liu ' A demo on how to: ' (1) Write text onto a background image with user-selected font, size and color, and ' optionally at a rotated angle, and allow the user to drag the text to anywhere on ' the background image with due speed and ease. ' (2) Enable cut, copy and/or paste of a region of the current image, or copy the whole ' image to clipboard. ' (3) Superimpose an image on the existing one and allow the user to drag it to any ' desired position to blend in. Through clipboard the added image may originate from ' an external program such as a clip art or an art text from Word. Alternatively it ' may come directly from a file. In either case, user may retrieve it as opaque or ' as transparent. ' (4) Resize the picture by dragging its edges, auto-scroll region at edge, etc. '----------------------------------------------------------------------------------------- ' Acknowledgement: Subsequent to the original posting, anti-alias is added in rotating text. ' The subroutine of anti-alias is learnt from the excellent code of Twan van Laarhoven. '----------------------------------------------------------------------------------------- ' Remarks: To avoid complicating the issue, only one or two text submenu items under the ' Text menu are made available for demo purposes; others are dimmed as some of them involve ' some other API calls. '----------------------------------------------------------------------------------------- Option Explicit Private Declare Function BitBlt Lib "gdi32" (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 Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _ ByVal y As Long, ByVal mDestWidth As Long, ByVal mDestHeight As Long, _ ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal mSrcWidth As Long, _ ByVal mSrcHeight As Long, ByVal dwRop As Long) As Long Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _ ByVal y As Long) As Long Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _ ByVal y As Long, ByVal crColor As Long) As Long Private Const Pi = 3.14159265359 Dim CurrW As Long Dim CurrH As Long Dim Red As Integer, Green As Integer, Blue As Integer Dim HRed As String, HGreen As String, HBlue As String Dim colorHex As String Dim Xold As Single Dim Yold As Single Dim X1Reg As Single Dim X2Reg As Single Dim Y1Reg As Single Dim Y2Reg As Single Dim Xcurr As Single Dim Ycurr As Single Dim Xprev As Single Dim Yprev As Single Dim Xoffset As Single Dim Yoffset As Single Dim Xmin As Single Dim Ymin As Single Dim Xmax As Single Dim Ymax As Single Dim BrushSize As Integer Dim mFileSpec As String Dim mSuspend As Boolean Dim ImageLoaded As Boolean Dim mDirty As Boolean Dim AllowUndoFlag As Boolean Dim RegionFlag As Boolean Dim RegionMoveReadyFlag As Boolean Dim PasteOnFlag As Boolean Dim TransparentFlag As Boolean Dim ColorChangeFlag As Boolean Dim sizeHorizontal As Boolean Dim sizeVertical As Boolean Dim mResult Dim gCancel As Boolean Dim gcdg As Object Private Sub Form_Load() mSuspend = True picAuto.AutoSize = True Dim i cboFontName.Clear For i = 0 To Screen.FontCount - 1 cboFontName.AddItem Screen.Fonts(i) Next i For i = 0 To Screen.FontCount If cboFontName.List(i) = "Verdana" Then cboFontName.ListIndex = i Exit For End If Next i Set icb1Color3D.ImageList = ImageList1 icb1Color3D.Locked = True icb1Color3D.ComboItems.Clear Dim CI As ComboItem Set CI = icb1Color3D.ComboItems.Add(1, "UpperLeft", "U Left", "UpperLeft", , 0) Set CI = icb1Color3D.ComboItems.Add(2, "UpperRight", "U Right", "UpperRight", , 0) Set CI = icb1Color3D.ComboItems.Add(3, "LowerLeft", "L Left", "LowerLeft", , 0) Set CI = icb1Color3D.ComboItems.Add(4, "LowerRight", "L Right", "LowerRight", , 0) icb1Color3D.SelectedItem = icb1Color3D.ComboItems(1) cboShadeThickness.Clear For i = 1 To 9 cboShadeThickness.AddItem i Next i cboShadeThickness.ListIndex = 3 cboRotateAngle.Clear For i = -360 To 360 cboRotateAngle.AddItem i Next i cboRotateAngle.ListIndex = 360 ' Display an initial sample text angle HsbRotateAngle_Change ' Default Red = 0 Green = 64 Blue = 128 HRed = Format(Hex(Red), "00") HGreen = Format(Hex(Green), "00") HBlue = Format(Hex(Blue), "00") colorHex = HRed & HGreen & HBlue lblTextColor.Caption = "RGB(" & Red & ", " & Green & ", " & Blue & ") Hex: #" & colorHex picTextColor.BackColor = RGB(Red, Green, Blue) Set gcdg = CommonDialog1 mSuspend = False SizeForm End Sub Private Sub Form_Activate() If gCancel Then Unload Me Exit Sub End If End Sub ' Try to gain larger space on screen for image display Private Sub SizeForm() Dim X, y Dim w, h Dim picZOldWidth, picZOldHeight HideFrames fraRegion.Visible = False fraTextPanel.Visible = True fraRotateAngle.Visible = True fra1Color3D.Visible = True Me.WindowState = vbMaximized w = Screen.Width / Screen.TwipsPerPixelX h = Screen.Height / Screen.TwipsPerPixelY VScroll1.Left = w - VScroll1.Width - 5 VScroll1.Height = h - HScroll1.Height - 200 picZ.Width = w - picZ.Left - VScroll1.Width - 5 picZ.Height = VScroll1.Height HScroll1.Top = picZ.Top + picZ.Height HScroll1.Width = picZ.Width picDisp.Move 0, 0 lblImageSize.Top = HScroll1.Top + HScroll1.Height + 10 lblFileSpec.Top = lblImageSize.Top lblFileSpec.Width = picZ.ScaleWidth + VScroll1.Width picSnap.Width = picDisp.Width picSnap.Height = picDisp.Height picSnap.Move 0, 0 picUndo.Width = picDisp.Width picUndo.Height = picDisp.Height lblFileSpec = "......" CurrW = picDisp.ScaleWidth CurrH = picDisp.ScaleHeight setScrollMax lblImageSize.Caption = "W=" & CStr(CurrW) & " H=" & CStr(CurrH) ImageLoaded = True mDirty = False AllowUndoFlag = False RegionFlag = False RegionMoveReadyFlag = False PasteOnFlag = False WriteSample End Sub Private Sub HideFrames() picSnap.Visible = False picDisp.Visible = True fraRotateAngle.Visible = False fra1Color3D.Visible = False End Sub Private Sub WriteSample() If CInt(txtFontSize.Text) < 6 Or CInt(txtFontSize.Text) > 99 Then lblTextSample.Caption = "" Exit Sub End If lblTextSample.Caption = "Aa" If picTextColor.BackColor = vbWhite Then lblTextSample.BackColor = RGB(0, 0, 255) Else lblTextSample.BackColor = vbWhite End If lblTextSample.ForeColor = picTextColor.BackColor lblTextSample.Font = cboFontName.Text lblTextSample.Font.Size = CInt(txtFontSize.Text) lblTextSample.Font.Bold = (imgBold.Appearance = 1) lblTextSample.Font.Italic = (imgItalic.Appearance = 1) End Sub Private Sub setScrollMax() HScroll1.Max = picDisp.ScaleWidth - picZ.ScaleWidth VScroll1.Max = picDisp.ScaleHeight - picZ.ScaleHeight If HScroll1.Max <= 0 Then HScroll1.Max = 0 Else If picZ.ScaleWidth / HScroll1.Max < 1 Then HScroll1.SmallChange = 1 Else HScroll1.SmallChange = picZ.ScaleWidth / HScroll1.Max End If HScroll1.LargeChange = HScroll1.SmallChange If HScroll1.Max >= 40 Then HScroll1.LargeChange = HScroll1.Max / 20 If HScroll1.LargeChange < HScroll1.SmallChange Then HScroll1.LargeChange = HScroll1.SmallChange End If End If End If If VScroll1.Max <= 0 Then VScroll1.Max = 0 Else If picZ.ScaleHeight / VScroll1.Max < 1 Then VScroll1.SmallChange = 1 Else VScroll1.SmallChange = picZ.ScaleHeight / VScroll1.Max End If VScroll1.LargeChange = VScroll1.SmallChange If VScroll1.Max >= 40 Then VScroll1.LargeChange = VScroll1.Max / 20 If VScroll1.LargeChange < VScroll1.SmallChange Then VScroll1.LargeChange = VScroll1.SmallChange End If End If End If End Sub Private Sub cboFontName_Click() Dim objFont As New StdFont objFont.Name = cboFontName.Text If StrComp(cboFontName.Text, objFont.Name, vbTextCompare) = 0 Then WriteSample Else MsgBox cboFontName.Text & " not available in system." End If End Sub Private Sub cmdTextColor_Click() On Error GoTo errHandler Dim DialogNum imgColorPicker.Appearance = 0 gcdg.CancelError = True gcdg.Flags = cdlCFBoth gcdg.ShowColor DialogNum = gcdg.Color picTextColor.BackColor = DialogNum DispDialogColor DialogNum picDisp.SetFocus Exit Sub errHandler: picDisp.SetFocus If Err.Number <> 32755 Then ErrMsgProc "cmdTextColor_click" End If End Sub Sub DispDialogColor(inDialogNum) Blue = (inDialogNum \ &H10000) Mod &H100 Green = (inDialogNum \ &H100) Mod &H100 Red = inDialogNum Mod &H100 HRed = Format(Hex(Red), "00") HGreen = Format(Hex(Green), "00") HBlue = Format(Hex(Blue), "00") colorHex = HRed & HGreen & HBlue picTextColor.BackColor = RGB(Red, Green, Blue) WriteSample lblTextColor.Caption = "RGB(" & Red & ", " & Green & ", " & _ Blue & ") Hex: #" & colorHex picDisp.SetFocus End Sub Private Sub HScroll1_Change() picDisp.Left = -HScroll1.Value End Sub Private Sub HScroll1_Scroll() picDisp.Left = -HScroll1.Value End Sub Private Sub VScroll1_Change() picDisp.Top = -VScroll1.Value End Sub Private Sub VScroll1_Scroll() picDisp.Top = -VScroll1.Value End Sub Private Sub imgColorPicker_Click() If ImageLoaded = False Then Exit Sub End If If imgColorPicker.Appearance = 1 Then imgColorPicker.Appearance = 0 Else imgColorPicker.Appearance = 1 End If End Sub Private Sub imgRegion_Click() If ImageLoaded = False Then Exit Sub End If imgRegion.Appearance = Abs(imgRegion.Appearance - 1) fraTextPanel.Visible = imgRegion.Appearance = 0 If imgRegion.Appearance = 1 Then mnuToolsRegion.Checked = True ' Transparency not applicable if Region TransparentFlag = False fraTextPanel.Visible = False Else mnuToolsRegion.Checked = False fraTextPanel.Visible = True End If imgColorPicker.Appearance = 0 ClearFlags End Sub Private Sub mnuFile_Click() mnuFileSave.Enabled = (ImageLoaded = True) 'mnuEilePrint.Enabled = (ImageLoaded = True) End Sub Private Sub mnuFileNew_Click() If mDirty Then Dim tmp tmp = MsgBox("Save current picture?", vbYesNoCancel + vbQuestion) If tmp = vbCancel Then Exit Sub ElseIf tmp = vbYes Then mnuFileSave_Click If gCancel Then Exit Sub End If End If End If picDisp.Picture = LoadPicture() picSnap.Picture = LoadPicture() picUndo.Picture = LoadPicture() picRegion.Picture = LoadPicture() picMask.Picture = LoadPicture() lblFileSpec.Caption = "" HScroll1.Value = 0 VScroll1.Value = 0 CurrW = picDisp.ScaleWidth CurrH = picDisp.ScaleHeight setScrollMax lblImageSize.Caption = "W=" & CStr(CurrW) & " H=" & CStr(CurrH) imgColorPicker.Appearance = 0 ImageLoaded = True mDirty = False picDisp.SetFocus Exit Sub End Sub Private Sub mnuFileOpen_Click() On Error GoTo errHandler If mDirty Then Dim tmp tmp = MsgBox("Save current picture?", vbYesNoCancel + vbQuestion) If tmp = vbCancel Then Exit Sub ElseIf tmp = vbYes Then mnuFileSave_Click If gCancel Then Exit Sub End If End If End If gcdg.Filter = "(bmp, gif)|*.bmp;*.gif|(*.*)|*.*|" gcdg.FilterIndex = 1 gcdg.DefaultExt = "bmp" gcdg.Flags = cdlOFNFileMustExist gcdg.FileName = "" gcdg.CancelError = True gcdg.ShowOpen If gcdg.FileName = "" Then picDisp.SetFocus Exit Sub End If mFileSpec = gcdg.FileName picDisp.Picture = LoadPicture() picDisp.AutoSize = True picDisp.Picture = LoadPicture(mFileSpec) picDisp.AutoSize = False picSnap.Picture = LoadPicture() picSnap.Width = picDisp.Width picSnap.Height = picDisp.Height picUndo.Picture = LoadPicture() picUndo.Width = picDisp.Width picUndo.Height = picDisp.Height picRegion.Picture = LoadPicture() picMask.Picture = LoadPicture() lblFileSpec.Caption = mFileSpec HScroll1.Value = 0 VScroll1.Value = 0 CurrW = picDisp.ScaleWidth CurrH = picDisp.ScaleHeight setScrollMax lblImageSize.Caption = "W=" & CStr(CurrW) & " H=" & CStr(CurrH) imgColorPicker.Appearance = 0 ImageLoaded = True mDirty = False picDisp.SetFocus Exit Sub errHandler: picDisp.SetFocus If Err <> 32755 Then ErrMsgProc "mnuFileOpen_Click" End If End Sub Private Sub mnuFileSave_Click() On Error GoTo errHandler gCancel = False picDisp.Refresh imgColorPicker.Appearance = 0 HScroll1.Value = 0 VScroll1.Value = 0 Dim mPath As String mPath = CurDir mFileSpec = lblFileSpec.Caption gcdg.FileName = mFileSpec gcdg.Filter = "Bitmap files (*.bmp)|*.bmp|(*.*)|*.*|" gcdg.DefaultExt = "bmp" gcdg.FilterIndex = 1 gcdg.Flags = cdlOFNOverwritePrompt gcdg.CancelError = True gcdg.ShowSave mFileSpec = gcdg.FileName SavePicture picDisp.Picture, mFileSpec lblFileSpec.Caption = mFileSpec ChDir mPath mDirty = False Exit Sub errHandler: If Err <> 32755 Then ErrMsgProc "mnuFileSave" Else gCancel = True End If End Sub Private Sub mnuFileExit_Click() Unload Me End Sub Private Sub mnuEdit_Click() mnuEditUndo.Enabled = (AllowUndoFlag = True) mnuEditCut.Enabled = (ImageLoaded = True) And RegionMoveReadyFlag = True mnuEditCopy.Enabled = (ImageLoaded = True) mnuEditPaste.Enabled = (ImageLoaded = True) And (Clipboard.GetFormat(vbCFBitmap) Or _ Clipboard.GetFormat(vbCFMetafile) Or Clipboard.GetFormat(vbCFDIB) Or _ Clipboard.GetFormat(vbCFPalette)) mnuEditPasteTransparent.Enabled = mnuEditPaste.Enabled mnuEditPasteFromFile.Enabled = ImageLoaded mnuEditPasteFromFileTransparent.Enabled = ImageLoaded End Sub Private Sub DoBackUp() picDisp.Refresh If picUndo.ScaleWidth <> picDisp.ScaleWidth Or _ picUndo.ScaleHeight <> picDisp.ScaleHeight Then picUndo.Picture = LoadPicture() picUndo.Width = picDisp.Width picUndo.Height = picDisp.Height End If mResult = BitbltPic(picDisp, picUndo) AllowUndoFlag = True End Sub Private Sub mnuEditUndo_Click() RegionFlag = False RegionMoveReadyFlag = False PasteOnFlag = False If picUndo.ScaleWidth <> picDisp.ScaleWidth Or _ picUndo.ScaleHeight <> picDisp.ScaleHeight Then picDisp.Picture = LoadPicture() picDisp.Width = picUndo.Width picDisp.Height = picUndo.Height End If mResult = BitbltPic(picUndo, picDisp) imgColorPicker.Appearance = 0 HScroll1.Value = 0 VScroll1.Value = 0 AllowUndoFlag = False End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If mDirty Then Dim tmp tmp = MsgBox("Save current picture?", vbYesNoCancel + vbQuestion) If tmp = vbCancel Then Cancel = True Exit Sub ElseIf tmp = vbYes Then mnuFileSave_Click If gCancel Then Cancel = True Exit Sub End If End If End If End Sub Private Sub imgBold_Click() If imgBold.Appearance = 1 Then imgBold.Appearance = 0 Else imgBold.Appearance = 1 End If WriteSample End Sub Private Sub imgItalic_Click() If imgItalic.Appearance = 1 Then imgItalic.Appearance = 0 Else imgItalic.Appearance = 1 End If WriteSample End Sub Private Sub txtFontSize_KeyPress(KeyAscii As Integer) KeyAscii = FilterNumericKey(KeyAscii) End Sub Private Sub txtFontSize_change() If Trim(txtFontSize.Text) = "" Or Val(txtFontSize.Text) <= 0 Then txtFontSize.Text = 6 End If imgColorPicker.Appearance = 0 WriteSample End Sub Private Function PreVet() As Boolean If ImageLoaded = False Then MsgBox "No image loaded yet" PreVet = False Exit Function End If If Len(Trim(txbWriteText.Text)) = 0 Then MsgBox "No text entered yet" PreVet = False Exit Function End If If CInt(txtFontSize.Text) < 6 Or CInt(txtFontSize.Text) > 99 Then MsgBox "Limit font size to between 6 and 99" PreVet = False Exit Function End If PreVet = True End Function Private Function BitbltPic(SrcPic As Control, DestPic As Control) As Boolean On Error GoTo errHandler Dim SrcX As Long Dim SrcY As Long BitbltPic = True SrcX = SrcPic.ScaleWidth SrcY = SrcPic.ScaleHeight DestPic.Picture = LoadPicture() mResult = BitBlt(DestPic.hdc, 0, 0, SrcX, SrcY, SrcPic.hdc, 0, 0, vbSrcCopy) DestPic.Picture = DestPic.Image If mResult = 0 Then GoTo errHandler End If Exit Function errHandler: BitbltPic = False ErrMsgProc "BitbltPic" End Function Private Sub cmdCancel_Click(Index As Integer) HideFrames fraTextPanel.Visible = True fraRegion.Visible = True End Sub Private Sub mnuTools_Click() mnuToolsRegion.Enabled = ImageLoaded End Sub Private Sub mnuToolsRegion_Click() mnuToolsRegion.Checked = Not mnuToolsRegion.Checked fraRotateAngle.Visible = False fra1Color3D.Visible = False fraRegion.Visible = True If mnuToolsRegion.Checked Then imgRegion.Appearance = 1 Else imgRegion.Appearance = 0 End If fraTextPanel.Visible = fraRegion.Visible And imgRegion.Appearance = 0 End Sub Private Sub mnuText_Click() imgColorPicker.Appearance = 0 imgRegion.Appearance = 0 fraTextPanel.Visible = True 'Dim i 'For i = 0 To 7 ' mnuTextWrite(i).Enabled = ImageLoaded and Not (fraTextWrite(i).Visible) 'Next i mnuTextWrite(4).Enabled = ImageLoaded And Not (fra1Color3D.Visible) End Sub Private Sub mnuTextWrite_Click(Index As Integer) ClearFlags picDisp.Cls HideFrames fraRotateAngle.Visible = True fraRegion.Visible = False If Index = 4 Then fra1Color3D.Visible = True End If Exit Sub End Sub Private Sub cmd1color3dProceed_click() If Not PreVet Then Exit Sub End If On Error Resume Next Screen.MousePointer = vbHourglass imgColorPicker.Appearance = 0 HScroll1.Value = 0 VScroll1.Value = 0 Dim mDirection As Integer Dim i As Integer, j As Integer Dim tmp As String Dim colorRGB Dim r As Integer, g As Integer, b As Integer Dim X, y, X2, Y2 Dim transp As Long Dim isAntiAlias As Boolean Dim posX As Long, posY As Long Dim w, h picTemp.Picture = LoadPicture() picRegion.Picture = LoadPicture() picMask.Picture = LoadPicture() DoBackUp BitbltPic picDisp, picSnap SetupFont picTemp ' Size picTemp to fit text picTemp.Width = picTemp.TextWidth(txbWriteText.Text) + 10 picTemp.Height = picTemp.TextHeight(txbWriteText.Text) + 10 If picTemp.Width >= picDisp.Width Then picTemp.Width = picDisp.Width If picTemp.Height >= picDisp.Height Then picTemp.Height = picDisp.Height tmp = Right(lblTextColor.Caption, 6) HRed = Left(tmp, 2) HGreen = Mid(tmp, 3, 2) HBlue = Right(tmp, 2) r = CInt("&H" & HRed) g = CInt("&H" & HGreen) b = CInt("&H" & HBlue) colorRGB = RGB(r, g, b) picSnap.ScaleMode = vbTwips picTemp.ScaleMode = vbTwips j = CInt(cboShadeThickness.Text) * Screen.TwipsPerPixelX If r > 255 - j Then r = 255 - j If g > 255 - j Then g = 255 - j If b > 255 - j Then b = 255 - j Select Case icb1Color3D.SelectedItem.Index ' 1-based Case 1 X = 2: y = 2 ' Just a little bit away from 0. x & y are to increase mDirection = 1 Case 2 X = 2 + j: y = 2 mDirection = 2 Case 3 X = 2 + j: y = 2 + j mDirection = 3 Case 4 X = 2: y = 2 + j mDirection = 4 End Select ' Start to print For i = 0 To j If mDirection = 1 Then PrintAtPosFilterWhite picTemp, X + i, y + i, colorRGB, txbWriteText ElseIf mDirection = 2 Then PrintAtPosFilterWhite picTemp, X - i, y + i, colorRGB, txbWriteText ElseIf mDirection = 3 Then PrintAtPosFilterWhite picTemp, X - i, y - i, colorRGB, txbWriteText ElseIf mDirection = 4 Then PrintAtPosFilterWhite picTemp, X + i, y - i, colorRGB, txbWriteText End If colorRGB = RGB(r + i, g + i, b + i) Next i tmp = Right(lblTextColor.Caption, 6) ' Restore back to vbPixels picSnap.ScaleMode = vbPixels picTemp.ScaleMode = vbPixels ' Obtain the region size capable to accommodate a rotated text at any angle X = SizeToRotateRegion(picTemp) ' Size picRegion accordingly picRegion.Width = picRegion.Width - picRegion.ScaleWidth + X picRegion.Height = picRegion.Height - picRegion.ScaleHeight + X ' Rotate text onto picRegion transp = CLng(picRegion.Point(0, 0)) isAntiAlias = False posX = picRegion.ScaleWidth / 2 posY = picRegion.ScaleHeight / 2 picRegion.Cls RotatePic picTemp, picRegion, HsbRotateAngle.Value, True, transp, isAntiAlias, posX, posY picRegion.Refresh ' Prepare a mask if this approach is adopted picMask.Width = picRegion.Width picMask.Height = picRegion.Height BitbltPic picRegion, picMask CreateMask picMask, vbBlack SetPrevAndCurrValues 0, 0 SetLeeWay picRegion, picDisp, 80 ' Impute flags PasteOnFlag = True TransparentFlag = True RegionMoveReadyFlag = True imgRegion.Appearance = 1 fraTextPanel.Visible = False ' Since imgRegion.Appearance is set to 1 X1Reg = 0 X2Reg = 0 X2Reg = picRegion.ScaleWidth - 1 Y2Reg = picRegion.ScaleHeight - 1 UpdateRegionDragging fra1Color3D.Visible = False fraRegion.Visible = True mDirty = True HideFrames picDisp.SetFocus Screen.MousePointer = vbDefault End Sub Private Sub SetupFont(inPic As Object) inPic.Font.Name = cboFontName.Text inPic.Font.Size = CInt(txtFontSize.Text) inPic.ForeColor = picTextColor.BackColor If imgBold.Appearance = 1 Then inPic.Font.Bold = True Else inPic.Font.Bold = False End If If imgItalic.Appearance = 1 Then inPic.Font.Italic = True Else inPic.Font.Italic = False End If End Sub Private Sub PrintAtPosFilterWhite(ByVal inPic As PictureBox, ByVal X As Single, _ ByVal y As Single, ByVal inColor As Long, ByVal inText As String) ' Note here we don't use real whole white &HFFFFFF, but a very near one &HFFEEFF, ' so that it is visible (1) when printered on picRegionX (against its white ' background) and (2) when picRegion is combined with picMask later. Dim tmpColor As Long If inColor > &HFFEEFF Then tmpColor = &HFFEEFF Else tmpColor = inColor End If inPic.CurrentX = X inPic.CurrentY = y inPic.ForeColor = tmpColor inPic.Print inText End Sub Private Sub icb1Color3D_Click() picDisp.SetFocus imgColorPicker.Appearance = 0 End Sub Private Sub picDisp_MouseDown(Button As Integer, Shift As Integer, X As Single, y As Single) If Button <> vbLeftButton Then Exit Sub End If If picDisp.MousePointer = vbSizeWE Then Xold = X sizeHorizontal = True sizeVertical = False Exit Sub ElseIf picDisp.MousePointer = vbSizeNS Then Yold = y sizeVertical = True sizeHorizontal = False Exit Sub End If Dim w, h If imgColorPicker.Appearance = 1 Then ' Let MouseUp handle it Exit Sub ElseIf imgRegion.Appearance = 1 Then RegionFlag = True If RegionMoveReadyFlag = False Then picDisp.Cls X1Reg = X: X2Reg = X: Y1Reg = y: Y2Reg = y DrawRegionLines Else ' If the MouseDown point is not within existing region, then ' not to flag RegionMovaReadyFlag, if one exists, cancel it. If Not ((X >= X1Reg And X <= X2Reg) And (y >= Y1Reg And y <= Y2Reg)) Then picDisp.Cls ' Clear dotted lines DoBackUp ClearFlags Exit Sub End If '---------------------------------------------------------------------- ' Notes values of Xprev, Yprev, Xcurr, Ycurr, Xoffset and Yoffset ' are initiated in PrepareRegionDragging (or Paste ...), and Xprev and ' Yprev are updated in UpdateRegionDragging '---------------------------------------------------------------------- Xoffset = Xcurr - X Yoffset = Ycurr - y End If End If End Sub Private Sub picDisp_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single) SetMousePointer X, y Dim w, h If sizeHorizontal Or sizeVertical Then If sizeHorizontal Then picDisp.Width = picDisp.Width + (X - Xold) Xold = X mDirty = True CurrW = picDisp.ScaleWidth lblImageSize.Caption = "W=" & CStr(CurrW) & " H=" & CStr(CurrH) DoEvents Else picDisp.Height = picDisp.Height + (y - Yold) Yold = y mDirty = True CurrH = picDisp.ScaleHeight lblImageSize.Caption = "W=" & CStr(CurrW) & " H=" & CStr(CurrH) DoEvents End If ElseIf imgRegion.Appearance = 1 Then If RegionFlag = False Then Exit Sub End If If Not RegionMoveReadyFlag Then ' Then draw a new rectangle DrawRegionLines X2Reg = X: Y2Reg = y DrawRegionLines ' AutoScrollAtEdge is to enable a continuous draw of region lines when ' the region area extends beyond the viewport. ' For region drawing, have to test x and y here rather than entirely rely ' on AutoScrollAtEdge so that the mouse pointer can be retreated a little ' from the edge without triggering AutoScrollAtEdge (thus avoiding the ' unsolvable loop when, e.g., region is about the same height as picZ) If X >= (picZ.ScaleWidth + HScroll1) Or y >= (picZ.ScaleHeight + VScroll1) Or _ X <= HScroll1 Or y <= VScroll1 Then If AutoScrollAtEdge Then picDisp.Refresh End If End If Else Xcurr = X + Xoffset Ycurr = y + Yoffset If Xcurr < Xmin Then Xcurr = Xmin If Xcurr > Xmax Then Xcurr = Xmax If Ycurr < Xmin Then Ycurr = Xmin If Ycurr > Ymax Then Ycurr = Ymax X1Reg = Xcurr X2Reg = X1Reg + picRegion.ScaleWidth Y1Reg = Ycurr Y2Reg = Y1Reg + picRegion.ScaleHeight UpdateRegionDragging End If End If End Sub Private Sub picDisp_MouseUp(Button As Integer, Shift As Integer, X As Single, y As Single) On Error Resume Next If ImageLoaded = False Then Exit Sub End If RegionFlag = False mDirty = True If sizeHorizontal Or sizeVertical Then sizeHorizontal = False sizeVertical = False imgColorPicker.Appearance = 0 picSnap.Picture = LoadPicture() picSnap.Width = picDisp.Width picSnap.Height = picDisp.Height picUndo.Picture = LoadPicture() picUndo.Width = picDisp.Width picUndo.Height = picDisp.Height BitbltPic picDisp, picSnap picDisp.Picture = LoadPicture() BitbltPic picSnap, picDisp picSnap.Picture = LoadPicture() setScrollMax mnuEditUndo.Enabled = False ElseIf imgColorPicker.Appearance = 1 Then imgColorPicker.Appearance = 0 picDisp.Cls picDisp.Picture = picDisp.Image picTextColor.BackColor = picDisp.Point(X, y) DispDialogColor picDisp.Point(X, y) WriteSample picDisp.SetFocus ElseIf imgRegion.Appearance = 1 Then RegionFlag = False ' The region should at least be one pixel size If (Abs(X2Reg - X1Reg > 1) And Abs(Y2Reg - Y1Reg > 1)) Then If RegionMoveReadyFlag = False Then RegionMoveReadyFlag = True ValidateForSwapXY TransparentFlag = False PrepareRegionDragging 'Else Continue to keep it True. We already have done ' PrepareRegionDragging previously; we just wait for ' user to further drag or do something else. End If Else picDisp.DrawMode = vbCopyPen picDisp.DrawStyle = vbSolid End If End If End Sub Private Function AutoScrollAtEdge() As Boolean Dim m Dim b1 As Boolean, b2 As Boolean m = 10 b1 = False: b2 = False If X2Reg > (picZ.ScaleWidth + HScroll1 - m) Then If (HScroll1.Value + HScroll1.LargeChange) < HScroll1.Max Then HScroll1.Value = HScroll1.Value + HScroll1.LargeChange Else HScroll1.Value = HScroll1.Max End If b1 = True End If ' Have to first test if b1 is False, otherwise with a region approx the size of ' picZ is extended to wider then picZ, a conflicting situation would arise, i.e. ' both "X2Reg >..." and "X1Reg <..." become True. If b1 = False Then If X1Reg < (HScroll1 + m) Then If (HScroll1.Value - HScroll1.LargeChange) > HScroll1.Min Then HScroll1.Value = HScroll1.Value - HScroll1.LargeChange Else HScroll1.Value = HScroll1.Min End If b1 = True End If End If If Y2Reg > (picZ.ScaleHeight + VScroll1 - m) Then If (VScroll1.Value + VScroll1.LargeChange) < VScroll1.Max Then VScroll1.Value = VScroll1.Value + VScroll1.LargeChange Else VScroll1.Value = VScroll1.Max End If b2 = True End If If b2 = False Then If Y1Reg < (VScroll1 + m) Then If (VScroll1.Value - VScroll1.LargeChange) > VScroll1.Min Then VScroll1.Value = VScroll1.Value - VScroll1.LargeChange Else VScroll1.Value = VScroll1.Min End If b2 = True End If End If AutoScrollAtEdge = b1 Or b2 End Function Private Sub picSnap_MouseUp(Button As Integer, Shift As Integer, X As Single, y As Single) If ImageLoaded = False Then Exit Sub End If Screen.MousePointer = vbHourglass DoBackUp Dim mSpotColor As Long Dim w, h Dim i, j Dim c As Long w = picSnap.ScaleWidth h = picSnap.ScaleHeight ' picSnap is ready for use here since menu clicked mSpotColor = picSnap.Point(X, y) Screen.MousePointer = vbDefault End Sub Private Sub ValidateXY() Dim tmp As Single If X1Reg > X2Reg Then tmp = X1Reg X1Reg = X2Reg X2Reg = tmp End If If Y1Reg > Y2Reg Then tmp = Y1Reg Y1Reg = Y2Reg Y2Reg = tmp End If End Sub Private Sub SetMousePointer(inX, inY) If imgRegion.Appearance = 1 Then If RegionMoveReadyFlag Then If (inX > X1Reg And inX < X2Reg) And (inY > Y1Reg And inY < Y2Reg) Then picDisp.MousePointer = vbSizeAll Else picDisp.MousePointer = vbCrosshair End If Else If inX >= picDisp.ScaleWidth - 2 Then picDisp.MousePointer = vbSizeWE ElseIf inY >= picDisp.ScaleHeight - 2 Then picDisp.MousePointer = vbSizeNS Else picDisp.MousePointer = vbCrosshair End If End If Else If inX >= picDisp.ScaleWidth - 2 Then picDisp.MousePointer = vbSizeWE ElseIf inY >= picDisp.ScaleHeight - 2 Then picDisp.MousePointer = vbSizeNS Else picDisp.MousePointer = vbDefault End If End If End Sub Sub SetLeeWay(inPic1 As Object, inPic2 As Object, inPercent As Integer) Xmin = (inPic1.ScaleWidth / 100 * inPercent) * -1 Ymin = (inPic1.ScaleHeight / 100 * inPercent) * -1 Xmax = inPic2.ScaleWidth - inPic1.ScaleWidth - Xmin Ymax = inPic2.ScaleHeight - inPic1.ScaleHeight - Ymin End Sub Sub SetPrevAndCurrValues(ByVal inX As Single, ByVal inY As Single) Xprev = inX Yprev = inY Xcurr = Xprev Ycurr = Yprev Xoffset = 0 Yoffset = 0 End Sub Private Sub DrawRegionLines() picDisp.DrawMode = vbInvert picDisp.DrawStyle = vbDot picDisp.Line (X1Reg, Y1Reg)-(X2Reg, Y2Reg), , B picDisp.DrawMode = vbCopyPen picDisp.DrawStyle = vbSolid End Sub Sub WhiteNonPaintArea(inPic As PictureBox, inColor As Long) On Error Resume Next Dim picHdc As Long Dim w As Long, h As Long Dim i, j w = inPic.ScaleWidth h = inPic.ScaleHeight picHdc = inPic.hdc For i = 0 To w + 1 For j = 0 To h + 1 If GetPixel(picHdc, i, j) = inColor Then SetPixel picHdc, i, j, &HFFFFFF End If Next j DoEvents Next i End Sub Sub CreateMask(inPic As PictureBox, inColor As Long) On Error Resume Next Dim picHdc As Long Dim w As Long, h As Long Dim i, j w = inPic.ScaleWidth h = inPic.ScaleHeight picHdc = inPic.hdc For i = 0 To w + 1 For j = 0 To h + 1 If GetPixel(picHdc, i, j) <> &HFFFFFF Then SetPixel picHdc, i, j, inColor End If Next j DoEvents Next i End Sub Private Sub mnuEditCut_Click() On Error Resume Next If ImageLoaded = False Then MsgBox "No picture loaded yet" Exit Sub End If If X2Reg = 0 Or Y2Reg = 0 Then MsgBox "No picture region yet" Exit Sub End If If RegionMoveReadyFlag Then picDisp.Cls End If DoBackUp mnuEditCopy_Click ' Create a hole picDisp.Line (X1Reg, Y1Reg)-(X2Reg - 1, Y2Reg - 1), picDisp.BackColor, BF picDisp.Picture = picDisp.Image ClearFlags mDirty = True End Sub Private Sub mnuEditCopy_Click() On Error Resume Next If ImageLoaded = False Then MsgBox "No picture loaded yet" Exit Sub End If picDisp.Cls Dim X, y, w, h, w2, h2 If RegionMoveReadyFlag Then X = X1Reg y = Y1Reg w = X2Reg - X1Reg + 1 h = Y2Reg - Y1Reg + 1 picAuto.AutoSize = False picAuto.Picture = LoadPicture() picAuto.Width = picAuto.Width - picAuto.ScaleWidth + w picAuto.Height = picAuto.Height - picAuto.ScaleHeight + h picDisp.Cls mResult = BitBlt(picAuto.hdc, 0, 0, w, h, picDisp.hdc, X, y, vbSrcCopy) Clipboard.SetData picAuto.Image, vbCFBitmap picAuto.AutoSize = True DrawRegionLines Else Clipboard.SetData picDisp.Picture, vbCFBitmap End If End Sub Private Sub mnuEditPaste_Click() TransparentFlag = False PasteProc End Sub Private Sub mnuEditPasteTransparent_Click() TransparentFlag = True PasteProc End Sub Private Sub PasteProc() If Not (Clipboard.GetFormat(vbCFBitmap) Or _ Clipboard.GetFormat(vbCFMetafile) Or _ Clipboard.GetFormat(vbCFDIB) Or _ Clipboard.GetFormat(vbCFPalette)) Then MsgBox "No picture in clipboard yet" Exit Sub End If ' There mar.Sub y End If P PasteProc() s Picon AsasteOnFlag = Fa Dh > X2Reg Then cZ) eg .Yight + hata pic Picon A Yight + hatFor j = 0 T If pieg > Y2Reg Then > X2Reg Then eg > Y2Reg Then > X2eighExit Sub EndDisp.Width + (X - Xold) Xold = X mDirty = True 1ld = X idthmyl1.LargeChang) cDi SetPixel p= p, ByVal inY As Sing Xold mar.to.m eg .Yight + hhen > X2Reg Then > X2eighExit Sub EndDisp.Width + irentFlag = TA For i = 0 To w + 1 i = 0 To w arent_Click() To w arent_Click() ax = inPic2.Scale_Click() ax = inHmDirTo w arent_Clicp.Width + irent nHmDirTo ir b2 = False If X+ hat X idthmyl eg .Yight + End SubMectiidth pTo ir myl eg .Yight + End SubMectiidtHourglass ubMectiidtHourglass ubMecti pTo o mnuEhen tbltit Exit <Box "No pi EndDisp.Width nuEhen tshal ipicAuto.Scauld at least be one pix tshal ipi yet" ,ght + hClipXSub nuEhen tll1 - m) Then g .icale_Cto 1 picTemp.TrgeChang) N If Imagelick() tll1 - m) Then g .icale_Cto 1 picTemp.TrWhite elick() tll1 - m) Tdhite elick()t 3idth picU + 1 h = Y2Reg y En h = Y2Reg y En h = Y2Reg y En h = Y2Reg y En h = Y2Reg Private Sub cmd1color3dProceeeeeeeeeeeeeeeeeeeeeee1 xtWrite_Clicttm"Snap F en g .icale F en g .ical1) w) HBlue = Format(Hex(Blue), "00") isAntiAlias = c As Control) As Boolean On Error GoTo errHandler Reg = Xcure = yan If RegionMoveReadyFlag = False Then RegionMoveReadyFlag = True VaaleWid X2eighExit VaaleWid XXh Thenisp.MousePoi VaaleWid XYicon AsasteOnFlag = vbSrcCopy) Clip VaaleWidpicDispnFlag = vbSrcCopy) Clip VaaleWidpicDispnFlag = vbSrcCopy) Clip VaaleWidpicDispnFlag = vbSrcCoppicDispnFlag = en h so mDirty = ale_C h so mDirtyh hhMpicDisp_MousAs Single, ByVal inY As Single) XprTemp.TrWhite elick() eadyFlag = e, By .Y ' 1-based Case 1 X = 2: y = 2 ' Just a little bit away from 0. x & y are to increase mDirection = 1 Case 2 X = 2 + j: y = 2 mDirection = 2 Case 3 e 3 e 3 e 3 au 3 e 3 Reg, Y2Reg), , B picDispPictureBoi -------'s e 3 nHboard.GGGG picU + 1 rard.GGGG icU +s y End board.GGGG picU y End Ded = False To icU bSizeAll Else picDisp.MousePointer = vbCrosshair End If Else End SubMectiidtHusePointer = vbCTSubMsePo ter = tbue = Format(Hex(Blue), "b0Tem's e 3 r = FF Xof,Single, ByV) FF Xe = 0 MsePo = Xight + hae Privatsoll1.Value - ter = tnd Ded = F Vaa, B picDispvbCrItalic.AppeDis Private = F Vaa, Pointer = vbCTSubMsePo ter = tbue = F cDis-------'s e en = -HScroll1.Value End Sub Private Sub HSceeeeeeeeeeeee1 d yet" Ex Else izeAll Privai Privai aSl1.Value se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlP = -HScroll1.Value End Sub Private Sub HSceeeeeeeeeeevbDefault xe = 1 Pndth nuEhen nut Ex Elslalues(ByVal in(ByVal in(ByVal in(a izeAlbOn lbOn lb = 1 e se izeAlPtl/= nut Ex Elslalues(ByVal in bit away from 0. x & y away from 0. x & y are to incrAlPtlue se izeAlPtluh = Y2Reg y Privai aSl1.Value se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlue se izeAlPtlu+e se izeAlBx(Blue), "b0Tem's e 3 r = FF Xof,SingizeAlPck(tx picTextColor.BackColor = picDisr = p If (H,Mc1 picTemp.Trge1 As Boolean, b2 As Boolean m = mp = nsr = p If (H,Mc ElslSub HSceeeeeeeeeeevbDef ElslSub HSceeeeeeeeeeevbDef Elslssr = p I = Ht,2x = 2 isp.Cls tmpColor = inColor End If Picture = LoadPicture() eeevbDefault xe = 1 Pndth nuEhen nut DY2H = paGGGG ion = 2 Case 3 1 End SubMectiidtHour Ptlue w, h ion = 2 leWid XXh Thenisp.Mouslready have done e se izeAlPtli Private Sub mnuEditPasteTransparent_Click() TransparentFlag = True PasteProc End Sub ean, b2 As B ean, b > X2eigh (*.bmp)|*.b1 fr b e stFlag = b1 frg2 e stFlag = b1 frg2 e stFlag = b1 frg2 e stFlag End If If X2Reg >ue w,xel(pt ion i e se e l Just a little bit away from 0. x & y are to increase mDirection = 1 Case 2 DoE As BCancel Then zr i = 0 To w + DoE As BCancel Then zr iancel Then zr iancel Then zr iancel ointer = vbCTSubMsePo Click(Dispght = picRegion.Heig Privat zr iancee5 i e se e l JustbteTraePo ge Transparent_ay from zr i 1 Case 2 picDisr = p If ElsDisrl Jus' w' w' w' w' w' w' w' w' w' izeAlPtlue s2 I izeAlPtlue s2 I izeAlPtlue s2neue scrolf DrawRegi()EndDisp.Width + (X - Xoldfub vatG + (X - Xoldfub vatG + (Xh As Boolean rom zr , Pointer = vbCTSu2x = 2- Xoldfub vatG + (Xh As Boo;Zo ge Transparent_ay froX - Xoldfub vatG + ( uWidth + irentFlag = TA For i = 0 To w + 1 i = 0 To w arent_Click() To w arent_Click() ax = inPic2.Scale_Click() ax = inHmDirTo w arent_Clic,ale_Click() ax = inHmDirTo w arent_ClicStr(CurrW) & " Hc ' Create a w armfub vatG +cDient_Click() To w arent_Click() ax vate Sbue = For() To w aren zr i 1 pScroll1.Value .() Totlue k()earent_ay froX - Xollic,ale_Clic I.Visible) 'Nexw w' w' w' w' w'5e) 2i +s y E DrawRegi()Enub 3ed = ImageLoe-awRTransparent_ay froX - Xoldfu6 - Xonts hXoldfu6 - Xonts hXoldfu6 - Xent_ay fray fra Single,ngle, y As Single) If "eHScry = If "eHScry = If "eHScry = If "eHScry = If "eHScry = If "eHScrLCancellarentcDispPictureBoi -ancelnPic2.Scale_ izeAlP = otate leHeiws Object, w arse izeAlPtse izeAlPtli Private Sub mnuEditPasteotate leHeiws Objecx = inPic2.Scale_Click() Objecttlue se gcdg.FiltespnFlag = en se se picDisple_Clic I.Visible) c I.Visible) 3ed = ImageLrawRentered yet" nFlag cdg.CancelErrornerrHandler: picDisp.bi "eHScry isible) nFlag ceg, eIf imgRegion.Appea vbSrcCopy) fn.Apag ouseDcDisp.bi "eHScry isible)DcDisp.bi "e AutoS fn.ApAlPtlue se izeAlnpea vbSrcCopy) fn.Apag ouseDcDicry isible)DcDisp.bi "e AutoS fXn.ApAe.g., regionro=p To w + DoE As BCancel Themd1c regiononro=p To w + llMax mnuEditUndo.Enabled= gcdg seDcDicry isible)DcDisp.bi.Enabled= gcdg seDcDicry isibleon.ereIbHourt dg seDcDigClick() ax vate Sbue t - picAuto.ScaleHeight + ax vate SIcp.Width + irent nHmDirTo ir b2 = False If X+ hat X idthmyl eg .Yight + End SubMectiidth pTo ir myl eg .Yight + End SubMectiidtHourglass ubMectiidtHourglass ubMecti pTo o mnuEhen tbltit Exit <Box "No pi EndDistG d SubMectiidtHourglass ubMf pTo ir myl egsp.ivate Sub mnuEditPasteotate leHeiws Objecx otate leHeiwfs ubMf pTof pTof pTof pTof icDisp_Mo = True Elble)D= Trup_Mo = Tropy) "irTo2GG i2it Exit <Box "No pi ic = True SrcX = SrcPiue End Sub .oco pi ic = TMo = True Elble ndg s End Sub .oco pi ic = TMo = True Elble ndg s End Sub .oco pi ic = TMo = True Elble ndg s End Sub .oco pi ic = TMo = True Elble ndg s End Sub .oco pi ic = TMo = Tgle) Privatsoll1.f "eHScyollic,ale_Clic TMo = Tgle Elble ndg s End Sub .oco pi ic = TMo = True Elble ndg s End Sub .oco pi ic = TMo = Tgle) Privatsoll1.f "eHScyollic,ale_Clic TMo = Tgle Elble ndg s End Sub .oco pi ic = TMo = True Elble P = True El + (Xh w, h, w2, hP = True El +ieHSc End If Else e to incrA - Xoldfub G se .oco pi ic = TMo = Te Submt nHmDirToe 3 ousePointer w, h, wiTMo =iTMo = True Else w+e se FF Then picDileDcDisp.bi "se MectiidtHouA - Xoldfub G se .oco pi ic = TMo = Te Submt nHmDirToe 3 ousePointer w, h, wiTMo =iTMo = True Else w+e se FF Then picDileDcDisp.bi "se MectiidtHouA - Xoldfub G se .oco pi ic = TMo = Te Submt hF Thenit c = TMo = True sp.bi "se Fnair CHouAF The nHmDirTo "se For j = 0 Touai = piingle) Exit Sub End If If Regiont.oco pi iccccc(Mo = Tai = piingle) j = 0 Touai = piinglh, wiTMo =iTMl<"eHScr pi s End Sub .ote leHeiws Objecx = inem'sHeiws Objeceon = 1 c = TMt.Fil .ote ndg s End Sub DeDcDisot tnd Sub .ote le nHHoutle)DcDisp.ltndg s EnDeDcDisor .oco teDcDicMsgBoxirue tnd Sub .ote le nHHoutle)DcDisp.ltndg s EnDeDcDisor .oco teDcDicMsgBoxirue tnd Sub .ote le nHHoutle)DcDisp.ltndg s EnDeDcDisor .oco teDcDicMsgBoxirue tnd Sub .ote le nHHoutle)DcDisp.ltndg s EnDeDcDisor .oco new rectangle MpicDisp_MoupinPic A Elble n lbOn zctangset True dler: tbltit w, h, X <= HScv5uo teDcDicu) * 5uo tDcDita CDisp.Width + (X-si5p_ eMsgBoxirue > sSingle) ISingle) I ic = TMo = Te Se nHHoutle)DcDisp.d If e) I ic = TM) < HScroll1.Max Td Iae) r I ic = TM) < HScroll1.Mu Else e to incrA - End w' w' w' w'h If Imaged= gcdg seldfub G se .oco pi ic = mnuEhen tbltit Else se Te Se nHHoutl r I ic = TM) < HScroll1.=hen tb.oco pi ic = mnuE, m l1.=hen tb.oco= TMo = Tm l1. <= HScv5uo teDcDicu) * 5ui se Disp_MoupinPic A Elbl lbH Pr = Tm l1. <= H&cupin, wiTMo =ngle) I ic = hen,=3DestP Elble W=" & Sub Then YcuEn hw9.Tm l1. <= H&cupin, wis2eighExit Suhen YcuEn hw9.Tm l1. <= H&cupin, wis2eig1. <= Tai = piing2ic DoE 2I icx = ThenXm Elble ndg s End Sub .oco pi ic = TMo = True Elble P = True El + (Xh w, h, w2, hP = True El +ieHSc End If Else e to incrA - Xoldfub G se .oco pi ic = TMo = Te Submt nHmDirToe 3 ouseP Else e t i1. e le nHsScr piOg2ic DoE 2I icx e to inihen ' n e t en ll1.fe .nd Sub piOPixel p= p El + (Xh w, h, w2, hP =OPixIf (True izeAlP Y1Reg +Vl, w2, hP =OPixIf (True izeAlP Y1 vbSond Sub piOPixel p= p Edg s End Suwamt nHuwamt nHuwamt nHuwamt nHuwamt nHuwamt nHuwamt nHuw tb.oco pi ic = ro ir b2 = Fany<jsir b2oco pi ic h = Y2Reg - Y1Reg se Disp_Mo h = Y2Reg b2oco pi ic h =se e to incrA - Xorjsir b2oco pi ic sbSon en - XolI izeAlPtl/= nut Ex Elslalues(ByVal in bit away se Disp_Mo p.LincuEn ElslalueP ic h =se e to wb Y se Te Se nHHoutl r I ic =mnPic2.Scale_Clickcr piOeiwsb h =se e t =sckcr piOeiwsb h =se .()tl e to wb Y ic = TMisp.MousePointerj(ub prA irTo2rTo wrjsir bGB = RGB(r + ic Y ic = TMisp.Mou nHuwamt rA irTo2rTo wrjsir bo wi bo wi bo wi bo wi bo SrcX, SrcY, SrcPic.hdc, 0,tbo wi ic Y ic = r be ndg s End Sub .oco pi Mou nH9.Tm l1 Elble 0cfMisp.Mou nHuwamt rA< Y1Rt nHuwamt Exit <Box "No pi ble =se(ub prA Xold = X = ro2rTo wr, h =se Hyy< =se(ub prA Xold = X errHandler: ic =mnPrwb prA Xold se nut Ex Elslalues Xold se nut wr, Xolbi "eHScry isible)DcDisp.bi "e Au wrjsir bo Exit Sub e nHse e nHse erTo wrjsir h' "No pi ic pi ic pi ic pi ic pi ic nDeDcDisosible)w= TMo = Tru pi ic nDeDcDisosible)w= TMo Y Elslalues Xold se nut wr, Xolbi "eHScry isible)DcDisp.bi "e Au wrjsir b"e)DcDisp.bi ic Y nesp.bi "e Au wrjsir bo Exlsbi ic Y DcDi Xold =ymwb prvbDef ight,Y+m nHmDirToe 3 ouseE, m l1. 0 To w + 1 i = 0 To w arent_Cli pi ic )w= T .() Totlu1. 0 To w hLi " Else e to inc I ic =mnPic2.Scale_Cli To w hLi " Elic2.Scae) r I ic = TM) < HScroll1.Mu Else e to incrA - End w' w' w' w'h If Imaged= gcdg seldfub G se PdImaged= gcdg seldfub ndg s Exit < gcdg seldfub reldfub w' w' w' w'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''')''''''''''''' < ic = r be Xct" Exit Sub else. End If aC''''''c = r iinPic ic ic' w' w'h I8y = RGB(r + i, g + i, b + i) Next Xct" Exit''''''''''''''''''''''''''l-15i, seldfui)'''''lic ( seldfui)'''''lic ( seldfui)'''''lixt Xct"inP'c = r iinPic ictndg s ylse e stFlag = b1 frg2 e stFlag = izeAleb w' beyond tsizeVLmaged=O h =se =s ic = TMisp.Mou nHuwamt rA irTo2rTo wrjsir bo wi bo wi bo wi bo wi bo SrcX, SrcY, SrcPic.hdc, 0,tbo wi ic YZc, 0,tbo wi = Tru Tru Tru l/= pablsir bo wi pabl bo wi pabl bo wi pabl bo wi Hafub .uo teDcDicu) * 5uo tDub ir bo o teDcDicu) * 5uo tDcDu) * 5uo tDe'''''''''''')'''''''''''''ir bo 'ScrollAtEdgee''''''''ir b'''''''''i''''''''''''''''''ir boCm Exit <Box "No pi ble ent_ClicStr(Currced= gcdg seld e nHsee dgee'''cmd1,GB(r +b mnuEditPaste_.Wid seld Su = Xprev Ycurr = Yprev XoffmnuEditPaste_.Wid seld S pabl bo wi pab rA ir/ nHuwa ' n e.i pabaicMsg)cture() picUne nHHoutle)D2= RGB(r + i, g +r = Yprev Huwa f'''''''''''''''''ir boCm sg)cture()sg)tbo wi ic YZc, 0,tbo wi = Tru Tru Tru l/= pablsir bo wi pabl bo wi pabl bo wi pabl bo wi Hafub .uo teDcDicu) * 5uo tDub ir bo o teDcDicu) * 5uo tDcDu) * 5uo tDe'''''''''''')'''''''''''''ir bo 'ScrollAtEdgee''''''''ir b'''''''''''''''''''' 'ScrollAtEdgee'o pa N''''''ldfui)'''''lixt Xct"inP'c = r sp.1lixt nHuwamt tEdgee'o pa N'''''ee'o pa a Xct"inP'c = rp q = r sp.1lixt rp q y Privai aSl1rp q rp q y 'ject, w ar = r sp.1lixt r rp q'o pa tDe'''''''''''')'''''' Ycurr = y + Yoffset Else '''<a e.i ''' ' .uo teDca2: y = 2 + t '''<a e.i ''' ' .uo teDca2: y = 2 + t .Yight' ' .uo teDca2"No picty1) t ( C) t ( C) t c, i, j) <> &H(ic s vbDefault End If End If End Sub Sub SetLeeWay(inPic1 Asb Snd SubMectiidtHourgl ' If the 2(inPic1 Asb( (fui)'''''lic ( seldfui)'''''lic ( seldfui)'''''lixt Xct"inP'c seldfui)'''''lic ( seldfui)''''lic (uEhen nut DY2H = paGnuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu ThenX"f aCicDisp.ScaleWidcDisp.ScaleWidc seldfui)''''lic mageLoe-aHuwa f'''''wMode = vbInvert d IHic ( sel End If PleW pi dfui) No pi oScrollAtEdg-If otMScrollAt(yf( sel End If PleW pi dfui) No pi oScrollAtEdg-If otMScrollAt(yf( sel End If '- Xoldfub G s'''''nuuuuxt t' ' .uo teDca2"No picty1) t ( >ue w,xenonro=p To w = Tru Tru Tru l/= pablsir bo wi6 -ee picTextColor.BackColor = picDisr =x El= picDissp picSnap.Pictu3Pict = j'licn3'+-cDi2BackColor = picDisr =x 5ui CB(r +b mnu mafui)'+b mnu mafui)'+b mnu mafu +b mnu mafui)'b mnu mafui)'+b mnu mafu '+b m(eeeeeee1 zp q'o pa tDe'''''Uu errHandler: ic =mnPrwb prA Xold se nut g sNwnPrwb prA = picDisr =x El= picDissp picSnap.Pictu3Pict = j'licn3'+-cDi2BackColor = picDisr =x 5ui CB(r +b mnu mafui)'+b mnu mafui)'+b mnu mafu +b mnu mafui)'b mnu mafui)'+b mnu mafu '+b m(eeeeeee1 zp q'o pa tDe'''''Uu errHandler: crollAt(yf( sel nXm Elble .Scale_Click() picTextColor.BackColo h' "No pi ic pi ic picSnap.Picll1EIf o S:fui ''' n3 picP3 picP3 ppndlafui)'+b mnu mafu 'pl pAt(yf( sel End If mafu '+b m(eeeeeee1 fu f inX c d Sub .oco pi ic = TM.ScaleWidc E ) And (inY '''''''i''''Y2Reg - Y1Reg se c E ) End Ip.Picll1EIf o S:fui''''i'''Picllight .oco pi ic = TM.ScaleWid se c E ) End Ip.Pi-n'ntiAli(nu mafui)'D c E ) End Ip.Picll1EIf o S:fui''' Click(Dispght = picReY .ocoll1.Value ) )P 0u mafui)'D c E ) Endf o1.Value ) )P wa a a a se mnfu 'pc picTextCol Mh' "No pi ic pi ic WE e WE e -,q() ee e e kCosNY ocus imgColorPicker.Af icker.Af icker.Af X m Elble X m Elble se c E ) End nXm .Xm Elbl''lic (/= pablsir bo w End If Pic1 Asb Snd SubMectiidt,.Af & pablsir bose mDirtyb2oare to incrAlPtlue se izeAlPt u mDirtyb2oadE kCosNY ocun Else (ker.A se .oco pi ic = 5' ws ic = 5' ws ic = 5' ws icr .lhaO e i ' picSn mResult = BitBlt(picAuto.hdc, 0, 0, w, h, picDisp.hdc, X, y, vbSrcCopy) Clipboard.SetDa bo Exlsbi ic Y D, pic ElsebCopy) ag o oare to incrAlPtl Clip , y As Single) Se= TM.ScaleWid se c E ) End Ip.Pi-n'ntiAli(nu mafu i ' (l P End If Wid c mafu i ' i kCosNY w c (/= Min c Y D, pic El E ) s Picon AsasteOnFlahen,=3DestP Elb ' picSn mResult obo wi6 -ee rrnh E ) End Ip Ex Else izeAll mafui)'D c Ernh E -ResaleH'''''(nu mafu se wi bo0, w,PoiE -ResaleH''(nu mafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se wafu se waf