Graphics Question

  • Thread starter Thread starter SStory
  • Start date Start date
S

SStory

I need to be able to give the appearance of glass over a picture inside of a
frame.

How can I do this in real time given that the picture will change?

Is there a way using the graphics to make it look like the picture has glass
in front of it?

Thanks,

Shane
 
* "SStory said:
I need to be able to give the appearance of glass over a picture inside of a
frame.

How can I do this in real time given that the picture will change?

Is there a way using the graphics to make it look like the picture has glass
in front of it?

I am not sure what you mean by "look like the picture has glass in front
of it". 100 % transparent class? Do you want to simulate reflections?
 
Well, I am tryign to make a picture look like it is really ina picture
frame and need it to appear to have the glass over the picture? Any
suggestions? I am sure it would be reflections of some sort but have no idea
how to do it....

shane
 
* "SStory said:
Well, I am tryign to make a picture look like it is really ina picture
frame and need it to appear to have the glass over the picture? Any
suggestions? I am sure it would be reflections of some sort but have no idea
how to do it....

I am not sure how to do that too. The easiest way would be to overlay
another semitransparent image (PNG) that adds some effects to the
image. But I don't have a semitransparent PNG here at the moment, so I
cannot test it.
 
Thanks for the demo Ken, but I am looking I suppose for the White
reflections.

In Photoshop one would probably paint a few semi transparent white spots on
the photo to make it look as though the glass were reflecting a little light
and thus the picture would appear to be behind glass. Still not sure and
this
as much and art question as a "how to do it" in vb.net graphics question.

Do I need some sort of light source producing algorithm for that or what?
Maybe better just to forget the glass effect.

Thanks for the attempt.

Shane
 
Hi,

The shading models will not work for this application. Two suggestions
create a semi transparent white brush or brighten the image in certain
area to make it look like a light is shining on it. Hope this helps.

Dim bm As New Bitmap("Water lilies.jpg")
Dim brTexture As New
TextureBrush(Bitmap.FromFile("WoodTexture.gif"))
Dim p As New Pen(brTexture, 50)

Dim g As Graphics = Graphics.FromImage(bm)
Dim rDraw As Rectangle = New Rectangle(0, 0, bm.Width,
bm.Height)
Dim brWhite As New SolidBrush(Color.FromArgb(48, Color.White))
Dim gp As New GraphicsPath
gp.AddEllipse(bm.Width \ 2, bm.Height \ 2, 500, 500)

Dim regBrighten As New Region(gp)

For x As Integer = 0 To bm.Width - 1
For y As Integer = 0 To bm.Height - 1
Dim pt As New Point(x, y)
If regBrighten.IsVisible(pt) Then
Dim c As Color = bm.GetPixel(x, y)
Dim r, gr, b As Integer
gr = c.G
r = c.R
b = c.B
gr = CInt(gr * 1.8)
r = CInt(r * 1.8)
b = CInt(b * 1.8)

If gr > 255 Then gr = 255
If r > 255 Then r = 255
If b > 255 Then b = 255

c = Color.FromArgb(r, gr, b)
bm.SetPixel(x, y, c)
End If
Next
Next
g.DrawRectangle(p, rDraw)
g.FillEllipse(brWhite, 50, 50, 100, 100)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
PictureBox1.Image = bm


Ken
------------------------------

Ken Tucker said:
Hi,

Rod Stephens book Visual Basic Graphics programming has some vb classic
examples on shading models. I will look at it and see if I can upgrade
an example for you.

HYPERLINK
"http://www.vb-helper.com/vbgp.htm"http://www.vb-helper.com/vbgp.htm


Ken
------------------------

"SStory" <HYPERLINK
"mailto:[email protected]"TheStorys@TAKEOUTTHISSPA
MBUSTERsofthome.net> wrote in message
Thanks for the demo Ken, but I am looking I suppose for the White
reflections.

In Photoshop one would probably paint a few semi transparent white
spots
on
the photo to make it look as though the glass were reflecting a little
light
and thus the picture would appear to be behind glass. Still not sure
and

this
as much and art question as a "how to do it" in vb.net graphics
question.

Do I need some sort of light source producing algorithm for that or
what?

Maybe better just to forget the glass effect.

Thanks for the attempt.

Shane

"Ken Tucker [MVP]" <HYPERLINK
"mailto:[email protected]"HYPERLINK
"mailto:[email protected]"(e-mail address removed)> wrote in message
Hi,

Maybe this will work.
HYPERLINK
"HYPERLINK
"http://www.onteorasoftware.com/downloads/woodframe.zip"http://www.onteoraso
"http://www.onteorasoftware.com/downloads/woodframe.zip"http://www.onteoraso

ftware.com/downloads/woodframe.zip

Ken
---------------------

"Herfried K. Wagner [MVP]" <HYPERLINK
"mailto:[email protected]"HYPERLINK
"mailto:[email protected]"(e-mail address removed)> wrote in
message
news:[email protected]:
* "SStory" <HYPERLINK
"mailto:[email protected]"TheStorys@TAKEOUTTHISSPA
MBUSTERsofthome.net> scripsit:
Well, I am tryign to make a picture look like it is really ina
picture
frame and need it to appear to have the glass over the picture?
Any
suggestions? I am sure it would be reflections of some sort but
have
idea
how to do it....
I am not sure how to do that too. The easiest way would be to
overlay
another semitransparent image (PNG) that adds some effects to the
image. But I don't have a semitransparent PNG here at the moment,
so
I
cannot test it.
 
That is getting closer....
I think maybe I should use a gradient though--bright white in the middle and
moving towards transparent. And of course it needs shadows at the edge of
the picture to give the illusion of indention.

thanks Ken... I will try it with gradients... Haven't done one before but
hope I can figure that out. (have used Photoshop alot; just no experience
programming it.....yet.)
 
Hi,

I like how one this works out.

Dim brWhite As New LinearGradientBrush(rDraw, Color.FromArgb(40,
Color.White), Color.Transparent, 90, False)
Dim bl As New Blend

bl.Factors = New Single() {0.0F, 0.1F, 0.5F, 0.7F, 0.7F, 0.5F,
0.3F, 0.2F, 0}

bl.Positions = New Single() {0, 0.1F, 0.2F, 0.5F, 0.6F, 0.7F,
0.8F, 0.9F, 1.0F}

brWhite.Blend = bl
g.FillEllipse(brWhite, 50, 50, 100, 100)

Ken
 
Back
Top