Link to home
Start Free TrialLog in
Avatar of abbasi1
abbasi1Flag for Pakistan

asked on

frmaing a picture

1:- i want to format picture in such a way that i add a frame in its edges nicely and if there is some text description i can edit it as well such as i want to make a photoalbum in which i have to use frames to enhance its beauty and add text description for the memory that who is who in that picture? what will i do

2:- and if the frame make a round edge i cant cut picture in round shape or if the frame make a strry edges i can cut it as well just like a cookie cutter i can cutt the picture in different shapes like square, round, starry,bells shape and many more, is there any activex control or component in vb for that
Avatar of PlanetCpp
PlanetCpp

things like that don't need an activex component. if you learn a little GDI programming you'll be able to do it.
to add borders and shape the pictures you can use masks. say you want a border that's a picture frame, you draw the picture frame in some paint program and the part of the frame where the picture goes is left white or black, doesnt matter. now make a copy of that image and any area that you want to show over the photo are colored black and other areas that are to be transparent are made white.
load those two images up and use the BitBlt function to masks the image ont the photo
you first bitblt the mask image onto the photo using ropcode SRCAND (you'll see what that means later on)
then bitblt the actual image on using ropcode SRCPAINT
so if your image is a simple blue rectangle and your mask is all black rectangle with a white circle in the middle when you maks the images onto the photo the photo will have a blue border around it and itll show through the circle. im rusty in vb i can show you in c++ but i found a nice link
http://www.vbcodemagician.dk/tips/gfx_maskbitmap.htm
Avatar of abbasi1

ASKER

no it is not fullfilling my requirements rather to taly not actually i want i have a picture and i insert another picture on it in such a way that it will be on the back of the first picturemeans it will not on the first picture so that it will hide i want to emphasize the frame pic as well as the 2nd pic
thanks if any one help
abbasi
i didn't understand at all what you just posted, the way i suggested and the link i gave you shows you how to mak images onto each other, it wont completely hide the image thats behind it. any part that ytou want on the fram to be transparent will be with this method. your masking the frame onto the image so that the image shows through where its supposed to.
Avatar of abbasi1

ASKER

i just said that i want that i make such a thing which can become a picture frame
there is a picture with a hole in it  i want to insert picture in this hole
plz help me as early as u can
ok fine, that's what the link and info i gave you pointed to. just go the other way, if they select a frame you simple paint the photo in the area full, then paint the frame using masking. you don't want to have to go the other way by painting the frame then the photo. the end result is the same and the user would never know or care which one was on the window first, itll be a split second.
just have the frame in memory paint the photo, mask the frame.. thats all. its all right there.
not to repeat myself 100 times but i want to make sure you understand
the way i told you that if your frame was a simple blue square with a hole in the midde. your frame would be a blue square with whatever color hold you wanted in the middle, your mask image would be the same blue square but instead of the fame being blue itll be black, the hole will now be white. this is your mask.
when they select a photo and mask you simple draw the photo, then draw the mask using SRCAND
then draw the frame using SRCPAINT
thats all.
don't worry abotu which one is on the window first, put the frame or photo on first or whatever but when you go to draw the final result its
draw photo ropcode = SRCCOPY
draw mask ropcose = SRCAND
draw frame ropcode = SRCPAINT
easy..
Avatar of abbasi1

ASKER

sori can u give me any example code for that cuz i cant understand which u have said
plz help me as early as u can
ok, follow along cause i don't know if i can explain better then the webpage i gave you has, its simple just read.
first you need these declarations, put them in a module or in the forms general area, if you put it in the forms general area then you have to change public to private.
Public 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
Public Const SRCAND = &H8800C6
Public Const SRCCOPY = &HCC0020
Public Const SRCERASE = &H440328
Public Const SRCINVERT = &H660046
Public Const SRCPAINT = &HEE0086

now i don't know how your program is inputting the images, i assume your creating a new HDC and loading the bitmap into the it, but just to show you how to do this  start a new project and use all pictureboxes.
make 4 picture boxes, called "photo","frame","mask", and "result". find some photo that you want to use, then open up whichever paint program you use and make the frame (make it the same size as the photo). keep it simple for now, i just took a gradient fill from dark to light blue. now make a big circle or ellipse in the middle of the frame picture, make it black. this black area is where the photo will end up showing through.
save the frame. now what you need to do is have the black area on the frame be all white and any other area be black. so mess with the contrast and/or lower the color depth and use fills, anyway you know how to do it. just end up with a black and white photo, all black with a white ellipse or circle in the middle. use the frame picture cause the circles have to match up exactlly.
so now you have a photo of whatever, a frame thats some color rectangle same size as the photo with a black hole in the middle, and a mask which is the same size rectangle in black with a white hole in the middle.
add them to the appropriate picture box. ie, photo in photo, mask in mask etc etc.
now keep result blank but the same size as the other 4
and make the autodraw property = true (should be anyway) what you do is in a button write
Call BitBlt(Result.hDC, 0, 0, 320, 240, Photo.hDC, 0, 0, SRCCOPY)
Result.Refresh
Call BitBlt(Result.hDC, 0, 0, 320, 240, Mask.hDC, 0, 0, SRCAND)
Result.Refresh
Call BitBlt(Result.hDC, 0, 0, 320, 240, Frame.hDC, 0, 0, SRCPAINT)
Result.Refresh
and thats it, you should get the frame with the photo in the middle
to deal with images that are different sizes you get the size of the photo and use stretchblt instead of bitblt
you can look it up on MSDN, itll show you how you just specify two more width and height parameters.
this si the best i can explain this and with the webpage i gave you this should be very easy.
Avatar of abbasi1

ASKER

dont u have any example code for that
thanks if yes cuz its tough to handel
Abbasi
Avatar of abbasi1

ASKER

i m getting picture from file and then process it so then how to do this
dont u have any example code for that

thanks if yes cuz its tough to handel
thnks alot

Abbasi
ASKER CERTIFIED SOLUTION
Avatar of PlanetCpp
PlanetCpp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
abbasi1:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
Avatar of abbasi1

ASKER

i do care of it but i dont have any suitable answer