?
Solved

frmaing a picture

Posted on 2003-02-25
12
Medium Priority
?
204 Views
Last Modified: 2010-04-17
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
0
Comment
Question by:abbasi1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8023000
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
0
 
LVL 3

Author Comment

by:abbasi1
ID: 8028052
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
0
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8029618
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.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 3

Author Comment

by:abbasi1
ID: 8048941
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
0
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8049419
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..
0
 
LVL 3

Author Comment

by:abbasi1
ID: 8066526
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
0
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8068802
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.
0
 
LVL 3

Author Comment

by:abbasi1
ID: 8097870
dont u have any example code for that
thanks if yes cuz its tough to handel
Abbasi
0
 
LVL 3

Author Comment

by:abbasi1
ID: 8098161
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
0
 
LVL 6

Accepted Solution

by:
PlanetCpp earned 40 total points
ID: 8098826
i gave you example code right up there ^
just follow the directions, make the pictureboxes like i said and add the code
0
 

Expert Comment

by:CleanupPing
ID: 9447506
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.
0
 
LVL 3

Author Comment

by:abbasi1
ID: 9468888
i do care of it but i dont have any suitable answer
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Make the most of your online learning experience.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question