' ------------------------------------------------------------------------------------ ' Create an annotated picture ' This script takes the current picture and generates a new one with: ' - a green border: small on the top, left and right, large at the bottom ' - the comment of the picture is printed on the large bottom border ' - its name is derived from the original picture with "_cmt" appended. ' ------------------------------------------------------------------------------------ Option Explicit ' Constants that can be used with the DrawText nFormat parameter ' (from Microsoft documentation) Const DT_TOP = &H0 ' Specifies top-justified text (single line only). Const DT_LEFT = &H0 ' Aligns text flush-left. Const DT_CENTER = &H1 ' Centers text horizontally. Const DT_RIGHT = &H2 ' Aligns text flush-right. Const DT_VCENTER = &H4 ' Specifies vertically centered text (single line only). Const DT_BOTTOM = &H8 ' Specifies bottom-justified text (single line only). Const DT_WORDBREAK = &H10 ' Specifies word-breaking. Const DT_SINGLELINE = &H20 ' Specifies single line only. Carriage returns and ' linefeeds do not break the line. Const DT_EXPANDTABS = &H40 ' Expands tab characters. The default number of characters ' per tab is eight. Const DT_TABSTOP = &H80 ' Sets tab stops. The high-order byte of nFormat is the ' number of characters for each tab. Const DT_NOCLIP = &H100 ' Draws without clipping. Const DT_EXTERNALLEADING = &H200 'Includes the font’s external leading in the line height. ' Normally, external leading is not included in the ' height of a line of text. Const DT_CALCRECT = &H400 ' Determines the width and height of the rectangle. ' If there are multiple lines of text, DrawText will use ' the width of the rectangle pointed to by lpRect and ' extend the base of the rectangle to bound the last line ' of text. If there is only one line of text, DrawText ' will modify the right side of the rectangle so that it ' bounds the last character in the line. In either case, ' DrawText returns the height of the formatted text, but ' does not draw the text. Const DT_NOPREFIX = &H800 ' Turns off processing of prefix characters. Normally, ' DrawText interprets the ampersand (&) mnemonic-prefix ' character as a directive to underscore the character ' that follows, and the two-ampersand (&&) mnemonic-prefix ' characters as a directive to print a single ampersand. ' By specifying DT_NOPREFIX, this processing is turned off. Const DT_INTERNAL = &H1000 ' Uses the system font to calculate text metrics. Const DT_EDITCONTROL = &H2000 ' Duplicates the text-displaying characteristics of a ' multiline edit control. Specifically, the average ' character width is calculated in the same manner as for ' an edit control, and the function does not display a ' partially visible last line. Const DT_PATH_ELLIPSIS = &H4000 ' For displayed text, replaces characters in the middle ' of the string with ellipses so that the result fits in ' the specified rectangle. If the string contains backslash ' (\) characters, DT_PATH_ELLIPSIS preserves as much as ' possible of the text after the last backslash. Const DT_END_ELLIPSIS = &H8000 ' For displayed text, replaces the end of a string with ' ellipses so that the result fits in the specified ' rectangle. Any word (not at the end of the string) that ' goes beyond the limits of the rectangle is truncated ' without ellipses. Const DT_MODIFYSTRING = &H10000 ' Modifies the specified string to match the displayed ' text. This value has no effect unless DT_END_ELLIPSIS ' or DT_PATH_ELLIPSIS is specified. Const DT_RTLREADING = &H20000 ' Layout in right-to-left reading order for bi-directional ' text when the font selected into the hdc is a Hebrew or ' Arabic font. The default reading order for all text is ' left-to-right. Const DT_WORD_ELLIPSIS = &H40000 ' Truncates any word that does not fit in the rectangle ' and adds ellipses. Compare with DT_END_ELLIPSIS and ' DT_PATH_ELLIPSIS. Const DT_NOFULLWIDTHCHARBREAK = &H80000 ' Prevents a line break at a DBCS (double-wide ' character string), so that the line-breaking rule is ' equivalent to SBCS strings. For example, this can be ' used in Korean windows, for more readability of icon ' labels. This value has no effect unless DT_WORDBREAK ' is specified. Const DT_HIDEPREFIX = &H100000 ' Ignores the ampersand (&) prefix character in the text. ' The letter that follows will not be underlined, but ' other mnemonic-prefix characters are still processed. Const DT_PREFIXONLY = &H200000 ' Draws only an underline at the position of the character ' following the ampersand (&) prefix character. Does not ' draw any character in the string. const BORDER = 5 const BOTTOMBORDER = 50 ' Enough for two lines of text const backColor = 65280 ' Green background (0x00ff00) const textColor = 255 ' Red text const textBkColor = -1 ' Transparent background const font ="Arial,24,0,400,0,0,0" dim alb, pic, picNew, kPos, rect, k app.ClearTrace set alb = app.GetCurrentAlbum if not alb is nothing then ' Get the current picture and copy it to the cliboard kPos = alb.nCurrentPicture set pic = alb.GetVisiblePicture( kPos ) pic.copy(0) ' Create an empty new picture with a 50 pixel-high space at the bottom set picNew = alb.NewPicture( pic.w+2*BORDER, pic.h+BORDER+BOTTOMBORDER, 32, backColor ) ' Move the new picture just after the original picture alb.MovePicture picNew, kPos, True ' Paste the current picture into the new one leaving a 5 pixel border picNew.paste BORDER, BORDER ' Write the picture comment at the bottom of the new picture set rect = CreateObject("MyAlbum.rect") rect.x = 0 rect.y = pic.h + BORDER rect.w = pic.w rect.h = BOTTOMBORDER picNew.drawText pic.sComment, rect, font, textColor, textBkColor, DT_TOP or DT_CENTER or DT_NOPREFIX ' Copy the whole picture to the clipboard picNew.copy(0) alb.DeletePicture picNew set picNew = Nothing ' Now create a "real" picture with it's name derived from the original picture name dim filename filename = pic.sFileName k = instrrev( filename, "." ) ' The new picture will have "_cmt" appended to its name and will be a JPEG picture filename = left( filename, k-1 ) & "_cmt.jpg" ' Paste the picture on the clipboard to a new picture and save it alb.paste filename ' The new picture is at the end of the album, move it next to the original picture alb.MovePicture alb.GetPicture( alb.nbPicture-1 ), kPos, True alb.redraw end if