'-------------------------------------------------------------------------- ' StackPicPano.vbs ' I needed a picture showing how a stereo panoramic picture can be produce ' by the frames taken by a rotating camera. So I wrote this script that ' process a panoramic picture to build a picture showing a stack of frames. '-------------------------------------------------------------------------- Option Explicit const nbFrame = 81 const ratio = 0.666666666 const bShowStrip = True const PCT_YOFFSET = 50 const PCT_OVERLAP = 60 Dim alb, pic, i, wP, xS, yS, xP, yP, newPic, xOffset, xOverlap, yOffset, rect, xT, xTs, yTs, ix, iy, color, stripWidth App.ClearTrace set alb = app.GetCurrentAlbum set pic = alb.GetPicture( alb.CvtNumPic( alb.nCurrentPicture, True ) ) app.Trace "Processing picture: " & pic.sFileName app.Trace "Width =" & vbTab & pic.w app.Trace "Height =" & vbTab & pic.h wP = CLng(pic.h / ratio) xOffset = (pic.w - wP) / nbFrame yOffset = PCT_YOFFSET * xOffset / 100 stripWidth = xOffset 'wP / 20 xOverlap = PCT_OVERLAP * xOffset / 100 app.Trace "xOffset =" & vbTab & xOffset app.Trace "yOffset =" & vbTab & yOffset set newPic = alb.NewPicture( wP + (nbFrame-1) * xOverlap, pic.h + (nbFrame-1) * yOffset, 24, &hffffff ) set rect = CreateObject( "MyAlbum.rect" ) pic.Load True for i = 1 to nbFrame xS = (nbFrame-i) * xOffset yS = (i-1) * yOffset xT = (nbFrame-i) * xOverlap app.Trace "Frame #" & i & vbTab & "xS = " & xS & vbTab & "yS = " & yS pic.CopyRect xS, 0, xS+wP, pic.h, 0 newPic.Paste xT, yS if bShowStrip then xTs = CInt( xT + wP / 5 - stripWidth / 2 ) yTs = CInt(yS + pic.h) if i <> nbFrame then yTs = yS + yOffset for ix = xTs to xTs + stripWidth for iy = CInt(yS) to yTs color = newPic.getPixel( ix, iy ) newPic.setPixel ix, iy, lightenPixel( color, 1.5 ) next next xTs = CInt( xT + 4 * wP / 5 - stripWidth / 2 ) for ix = xTs to xTs + stripWidth for iy = CInt(yS) to yTs color = newPic.getPixel( ix, iy ) newPic.setPixel ix, iy, lightenPixel( color, 1.5 ) next next end if rect.x = xT rect.y = yS rect.w = wP rect.h = pic.h newPic.DrawRectangle rect, 1, 0, -1, DRAWRECT_RECT, 0,0 next set rect = Nothing alb.Redraw app.trace "Done!", -1, TRACE_GREENDOT function lightenPixel( color, factor ) dim r, g, b r = CInt( factor * ( color and &hff ) ) g = CInt( factor * ( fix( color / 256 ) and &hff ) ) b = CInt( factor * ( fix( color / 65536 ) and &hff ) ) if r > 255 then r = 255 if g > 255 then g = 255 if b > 255 then b = 255 lightenPixel = r + g * 256 + b * 65536 end function