473,322 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

set back ground image to stretch

how can i set a back ground image property on an MDI main form to stretch?
Mar 23 '06 #1
3 2620
Hi again,

in .net 2003 you have to resize the image your self via code, below is an
example that resizes the image and keeps the correct proportions, it
shouldn't be to hard to modify the code so the image stretches over the
entire form ignorig the proportions. This in fact would be less code then
the sample.

Hope this helps

Greetz, Peter

Private Sub loadimage(ByVal myFileName As String)
Try
Dim imgOrg As Bitmap
Dim imgShow As Bitmap
Dim g As Graphics

Dim delenDoor, delenDoorHO, delenDoorBR As Double
'delenDoor = divide by
'delenDoorHO = divide by height
'delenDoorBR = divide by width

imgOrg = DirectCast(Bitmap.FromFile(myFileName), Bitmap)

'Get the forms' dimensions
delenDoorBR = imgOrg.Width / Me.ClientSize.Width
delenDoorHO = imgOrg.Height / Me.ClientSize.Height
If delenDoorBR > 1 Or delenDoorHO > 1 Then
If delenDoorBR > delenDoorHO Then
delenDoor = delenDoorBR
Else
delenDoor = delenDoorHO
End If

imgShow = New Bitmap(CInt(CDbl(imgOrg.Width) / delenDoor),
CInt(CDbl(imgOrg.Height) / delenDoor))
imgShow.SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(imgShow)
g.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(imgOrg, New Rectangle(0, 0,
CInt(CDbl(imgOrg.Width) / delenDoor), CInt(CDbl(imgOrg.Height) /
delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pixel)
g.Dispose()
Else
imgShow = New Bitmap(imgOrg.Width, imgOrg.Height)
imgShow.SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(imgShow)
g.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(imgOrg, New Rectangle(0, 0, imgOrg.Width,
imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pixel)
g.Dispose()
End If
imgOrg.Dispose()

Me.BackgroundImage = imgShow
Me.Refresh()

Catch ex As Exception
MsgBox(ex.ToString)
End Try

End Sub

Private Sub form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'pass the image file you want to load
loadimage("c:\2_1024x768.jpg")
End Sub

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"mcnewsxp" <mc******@mindspring.com> schreef in bericht
news:Ot**************@TK2MSFTNGP10.phx.gbl...
how can i set a back ground image property on an MDI main form to stretch?

Mar 24 '06 #2
what if the image was placed on the form in the design window?

Me.BackgroundImage ?

"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi again,

in .net 2003 you have to resize the image your self via code, below is an
example that resizes the image and keeps the correct proportions, it
shouldn't be to hard to modify the code so the image stretches over the
entire form ignorig the proportions. This in fact would be less code then
the sample.

Hope this helps

Greetz, Peter

Private Sub loadimage(ByVal myFileName As String)
Try
Dim imgOrg As Bitmap
Dim imgShow As Bitmap
Dim g As Graphics

Dim delenDoor, delenDoorHO, delenDoorBR As Double
'delenDoor = divide by
'delenDoorHO = divide by height
'delenDoorBR = divide by width

imgOrg = DirectCast(Bitmap.FromFile(myFileName), Bitmap)

'Get the forms' dimensions
delenDoorBR = imgOrg.Width / Me.ClientSize.Width
delenDoorHO = imgOrg.Height / Me.ClientSize.Height
If delenDoorBR > 1 Or delenDoorHO > 1 Then
If delenDoorBR > delenDoorHO Then
delenDoor = delenDoorBR
Else
delenDoor = delenDoorHO
End If

imgShow = New Bitmap(CInt(CDbl(imgOrg.Width) / delenDoor),
CInt(CDbl(imgOrg.Height) / delenDoor))
imgShow.SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(imgShow)
g.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(imgOrg, New Rectangle(0, 0,
CInt(CDbl(imgOrg.Width) / delenDoor), CInt(CDbl(imgOrg.Height) /
delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pixel)
g.Dispose()
Else
imgShow = New Bitmap(imgOrg.Width, imgOrg.Height)
imgShow.SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(imgShow)
g.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(imgOrg, New Rectangle(0, 0, imgOrg.Width,
imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pixel)
g.Dispose()
End If
imgOrg.Dispose()

Me.BackgroundImage = imgShow
Me.Refresh()

Catch ex As Exception
MsgBox(ex.ToString)
End Try

End Sub

Private Sub form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'pass the image file you want to load
loadimage("c:\2_1024x768.jpg")
End Sub

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"mcnewsxp" <mc******@mindspring.com> schreef in bericht
news:Ot**************@TK2MSFTNGP10.phx.gbl...
how can i set a back ground image property on an MDI main form to
stretch?


Mar 24 '06 #3
I think it isn't possible in 2003 to strech the backgroundimage when it's
set via the design window

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"mcnewsxp" <mc******@mindspring.com> schreef in bericht
news:#A**************@TK2MSFTNGP12.phx.gbl...
what if the image was placed on the form in the design window?

Me.BackgroundImage ?

"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi again,

in .net 2003 you have to resize the image your self via code, below is an example that resizes the image and keeps the correct proportions, it
shouldn't be to hard to modify the code so the image stretches over the
entire form ignorig the proportions. This in fact would be less code then the sample.

Hope this helps

Greetz, Peter

Private Sub loadimage(ByVal myFileName As String)
Try
Dim imgOrg As Bitmap
Dim imgShow As Bitmap
Dim g As Graphics

Dim delenDoor, delenDoorHO, delenDoorBR As Double
'delenDoor = divide by
'delenDoorHO = divide by height
'delenDoorBR = divide by width

imgOrg = DirectCast(Bitmap.FromFile(myFileName), Bitmap)

'Get the forms' dimensions
delenDoorBR = imgOrg.Width / Me.ClientSize.Width
delenDoorHO = imgOrg.Height / Me.ClientSize.Height
If delenDoorBR > 1 Or delenDoorHO > 1 Then
If delenDoorBR > delenDoorHO Then
delenDoor = delenDoorBR
Else
delenDoor = delenDoorHO
End If

imgShow = New Bitmap(CInt(CDbl(imgOrg.Width) / delenDoor), CInt(CDbl(imgOrg.Height) / delenDoor))
imgShow.SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(imgShow)
g.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(imgOrg, New Rectangle(0, 0,
CInt(CDbl(imgOrg.Width) / delenDoor), CInt(CDbl(imgOrg.Height) /
delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pixel)
g.Dispose()
Else
imgShow = New Bitmap(imgOrg.Width, imgOrg.Height)
imgShow.SetResolution(imgOrg.HorizontalResolution,
imgOrg.VerticalResolution)
g = Graphics.FromImage(imgShow)
g.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(imgOrg, New Rectangle(0, 0, imgOrg.Width,
imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pixel)
g.Dispose()
End If
imgOrg.Dispose()

Me.BackgroundImage = imgShow
Me.Refresh()

Catch ex As Exception
MsgBox(ex.ToString)
End Try

End Sub

Private Sub form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'pass the image file you want to load
loadimage("c:\2_1024x768.jpg")
End Sub

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"mcnewsxp" <mc******@mindspring.com> schreef in bericht
news:Ot**************@TK2MSFTNGP10.phx.gbl...
how can i set a back ground image property on an MDI main form to
stretch?



Mar 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

182
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
3
by: Sridhar | last post by:
Hi, I have created a user control which has the html code as follows <TABLE id="ToolBarTable" cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr> <td align="right"...
4
by: John Swan | last post by:
Hello. I'm trying to create a simple program that amongst other things creates a thumbnail of an image (Bitmap) to a set size determined by the user in pixels? The problem is: All of the...
3
by: Keith G Hicks | last post by:
In MS Access image controls there's a property setting for "Size Mode" --> Clip, Zoom or Stretch. I don't see any similar property in an asp image control. When I have an image on a page, it seems...
9
by: tshad | last post by:
Is there a way to display images (imageButtons or linkbuttons for instance) as a max size (200px by 50px) and not have it stretch the image? What I want to be able to do is limit the real estate...
4
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I need to do a image viewer, just to view and zoom pictures in jpeg. I do not need to edit or save the picture. I am sure, there are some controls already made. I am thankful for any...
4
by: Bob Altman | last post by:
Hi all, I posted an earlier question to the microsoft.public.inetserver.asp.general newsgroup asking how to set the background of a client-side table cell to a gradient, and I received this...
176
by: . | last post by:
9/11 Mysteries http://video.google.com/videoplay?docid=-8172271955308136871 http://www.911weknow.com Ignore those who would go to great effort and expend much of heir time in poo-pooing this...
2
by: AAaron123 | last post by:
I have a pretty simple background image. Just a gradient using two colors. I like to uses a small image and have the browser stretch it. Is that possible. I did find the "repeat" but can not...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.