Filmstrip border overlay on existing image

Ultrawhack

Well-known member
Joined
Jul 5, 2006
Messages
164
Location
Canada
Programming Experience
3-5
Is it possible to use an image as a custom border around an image? Something like adding a film border around a existing bmp or jpeg ?

Basically I have images in a directory that I'd like to show in a form picturebox with a film strip border.
[FONT=Tahoma,Helvetica,Sans-Serif][/FONT]
[FONT=Tahoma,Helvetica,Sans-Serif]Thanks for any help[/FONT]
 
Place two Pictureboxes on form, one within the other and make the alignment for that 'frame' look.
 
Thanks. Is it possible to do this using GDI using filmstrip image as watermark overlay on an existing image ... and save the output as another image
 
Of course, but why the extra work?
Use the Bitmap class constructor to create new Bitmap. Get Graphics instance with the shared .FromImage function method. Use the Graphics class .DrawImage method to draw the images. Pseudo:
VB.NET:
dim bmp as new bitmap(100,100)
dim g as graphics = graphics.fromimage(bmp)
g.drawimage(...)
g.drawimage(...)
g.dispose()
 
Thanks for the pseudo. After your pointer I did a search and found this interesting code snippet here
VB.NET:
[COLOR=blue]Dim [/COLOR][COLOR=black]Circle [/COLOR][COLOR=blue]As [/COLOR][COLOR=black]Bitmap [/COLOR][COLOR=blue]= CType[/COLOR][COLOR=black](Image.FromFile([/COLOR][COLOR=#808080]"c:\circle.bmp"[/COLOR][COLOR=black]),Bitmap)
[/COLOR][COLOR=blue]Dim [/COLOR][COLOR=black]MergedBMP [/COLOR][COLOR=blue]As [/COLOR][COLOR=black]Bitmap [/COLOR][COLOR=blue]= CType[/COLOR][COLOR=black](Image.FromFile([/COLOR][COLOR=#808080]"c:\cross.bmp"[/COLOR][COLOR=black]),Bitmap)
[/COLOR][COLOR=blue]Dim [/COLOR][COLOR=black]g [/COLOR][COLOR=blue]As [/COLOR][COLOR=black]Graphics [/COLOR][COLOR=blue]= [/COLOR][COLOR=black]Graphics.FromImage(Circle)
MergedBMP.MakeTransparent(Color.White)
g.DrawImage(MergedBMP, [/COLOR][COLOR=maroon]0[/COLOR][COLOR=black], [/COLOR][COLOR=maroon]0[/COLOR][COLOR=black])
g.Dispose
pictureBox1.Image [/COLOR][COLOR=blue]= [/COLOR][COLOR=black]Circle[/COLOR]
My only problem is how to get the frame to resize and fit around the image...
 
Last edited:
You have to calculate, you have some options; (1) start with full image size and calculate how much border you want, then follow the previous sketch first draw background (=border) then draw real image at calculated center, or (2) fixed full size, draw background, draw real image streched inside.

I think you will find this site useful: Bob Powell GDI+ FAQ

You just have to decide how you want the two rectangles to lay out (you got a full image rectangle and the inner display image rectangle), calculate the rectangles according to any stretch/no-stretch requirements, then use drawimage method (there are several overloads for various input paramaters, look them up in documentation).

(Btw, the above code is C#)
 
Bob Powell's site is extremely valuable. Thanks. I understood what you said about sizing the 2 rectangles but I can't figure out how & where to size them in the code...
 
Back
Top