' ------------------------------------------------------------------------------------ ' MergePictures.vbs ' This script will "merge" the two selected pictures in the current album to generate ' a new one. ' The merge is done by taking, for each pixel, the max intensity of the R, G, and B ' component of the two pictures. ' Note: the two pictures to be merge must have the same size. ' ------------------------------------------------------------------------------------ Option Explicit dim alb, pic, pic1, pic2, picNew, nb, i, j, xSize, ySize, k, cr dim r, g, b, r2, g2, b2 app.ClearTrace set alb = app.GetCurrentAlbum if not alb is nothing and alb.nbSelectedPicture = 2 then ' Retrives the 2 selected pictures in the album nb = alb.nbPicture k = 1 set pic = alb.GetPicture( 0 ) for i = 0 to nb-1 if pic.bSelected then if k = 1 then set pic1 = pic k = 2 else set pic2 = pic end if end if set pic = pic.next next app.trace "Merging pictures " & pic1.sShortFileName & " and " & pic2.sShortFileName xSize = pic1.w ySize = pic1.h ' Create an empty new picture and make it the current one set picNew = alb.NewPicture( xSize, ySize, 32, 0 ) alb.nCurrentPicture = picNew.num 'xSize = 50 'ySize = 200 for j = 0 to ySize-1 app.Trace "Processing line " & j for i = 0 to xSize-1 cr = pic1.GetPixel(i,j) r = cr and &hff g = fix( cr / 256 ) and &hff b = fix( cr / 65536 ) and &hff cr = pic2.GetPixel(i,j) r2 = cr and &hff g2 = fix( cr / 256 ) and &hff b2 = fix( cr / 65536 ) and &hff if r2 > r then r = r2 if g2 > g then g = g2 if b2 > b then b = b2 'r = round( (r + (cr and &hff)) ) 'if r > 255 then r = 255 'g = round( (g + ((cr / 256) and &hff)) / 2) 'b = round( (b + ((cr / 65536) and &hff)) / 2) cr = r + g * 256 + b * 65536 'app.Trace cr picNew.SetPixel i, j, cr next next alb.redraw alb.DisplayPicture DP_CURRENT end if