473,761 Members | 8,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2649
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(Bitm ap.FromFile(myF ileName), Bitmap)

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

imgShow = New Bitmap(CInt(CDb l(imgOrg.Width) / delenDoor),
CInt(CDbl(imgOr g.Height) / delenDoor))
imgShow.SetReso lution(imgOrg.H orizontalResolu tion,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(imgShow)
g.Interpolation Mode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(img Org, New Rectangle(0, 0,
CInt(CDbl(imgOr g.Width) / delenDoor), CInt(CDbl(imgOr g.Height) /
delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pi xel)
g.Dispose()
Else
imgShow = New Bitmap(imgOrg.W idth, imgOrg.Height)
imgShow.SetReso lution(imgOrg.H orizontalResolu tion,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(imgShow)
g.Interpolation Mode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(img Org, New Rectangle(0, 0, imgOrg.Width,
imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pi xel)
g.Dispose()
End If
imgOrg.Dispose( )

Me.BackgroundIm age = imgShow
Me.Refresh()

Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try

End Sub

Private Sub form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) 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******@minds pring.com> schreef in bericht
news:Ot******** ******@TK2MSFTN GP10.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.BackgroundIm age ?

"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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(Bitm ap.FromFile(myF ileName), Bitmap)

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

imgShow = New Bitmap(CInt(CDb l(imgOrg.Width) / delenDoor),
CInt(CDbl(imgOr g.Height) / delenDoor))
imgShow.SetReso lution(imgOrg.H orizontalResolu tion,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(imgShow)
g.Interpolation Mode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(img Org, New Rectangle(0, 0,
CInt(CDbl(imgOr g.Width) / delenDoor), CInt(CDbl(imgOr g.Height) /
delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pi xel)
g.Dispose()
Else
imgShow = New Bitmap(imgOrg.W idth, imgOrg.Height)
imgShow.SetReso lution(imgOrg.H orizontalResolu tion,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(imgShow)
g.Interpolation Mode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(img Org, New Rectangle(0, 0, imgOrg.Width,
imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pi xel)
g.Dispose()
End If
imgOrg.Dispose( )

Me.BackgroundIm age = imgShow
Me.Refresh()

Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try

End Sub

Private Sub form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) 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******@minds pring.com> schreef in bericht
news:Ot******** ******@TK2MSFTN GP10.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******@minds pring.com> schreef in bericht
news:#A******** ******@TK2MSFTN GP12.phx.gbl...
what if the image was placed on the form in the design window?

Me.BackgroundIm age ?

"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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(Bitm ap.FromFile(myF ileName), Bitmap)

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

imgShow = New Bitmap(CInt(CDb l(imgOrg.Width) / delenDoor), CInt(CDbl(imgOr g.Height) / delenDoor))
imgShow.SetReso lution(imgOrg.H orizontalResolu tion,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(imgShow)
g.Interpolation Mode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(img Org, New Rectangle(0, 0,
CInt(CDbl(imgOr g.Width) / delenDoor), CInt(CDbl(imgOr g.Height) /
delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pi xel)
g.Dispose()
Else
imgShow = New Bitmap(imgOrg.W idth, imgOrg.Height)
imgShow.SetReso lution(imgOrg.H orizontalResolu tion,
imgOrg.Vertical Resolution)
g = Graphics.FromIm age(imgShow)
g.Interpolation Mode =
Drawing2D.Inter polationMode.Hi ghQualityBicubi c
g.DrawImage(img Org, New Rectangle(0, 0, imgOrg.Width,
imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pi xel)
g.Dispose()
End If
imgOrg.Dispose( )

Me.BackgroundIm age = imgShow
Me.Refresh()

Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try

End Sub

Private Sub form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) 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******@minds pring.com> schreef in bericht
news:Ot******** ******@TK2MSFTN GP10.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
7550
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
3
9396
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" bgColor="#000000"><IMG src="../Images/image1"> </td> </tr> <TR>
4
2573
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 examples I have seen so far are in c#. Can anyone please provide reference to a c++ managed version. Thanks. John
3
4751
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 to Stretch no matter what. If an image is displayed that has different proportions than the image control itself, the image is distorted. I need a "Zoom" setting (not to zoom in and out). How can this be done? Thanks, Keith
9
4419
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 an image can take up but not stretch the image if it happens to be 150px by 40. I am doing commands such as: <asp:ImageButton ID="CompanyLogo" onClick="Image_Click" Width="200px" Height="50px" runat="server"/>
4
6470
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 comment on that ! Best regards Frank Uray
4
5747
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 answer: How do I stretch the static image? The Style property builder for a table cell lets me specify the background image location, tiling, scrolling, and position. But I can't find any obvious way to tell it to stretch the image
176
4999
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 post. See for yourself what really happened in the 3 demolished buildings in the weeks before 9/11. Since 9-11 the American public has shown a "remarkable indifference to being deceived" (George Soros). But this is changing. As Hugo Chavez put it:
2
17228
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 find a "stretch" Is there one? Thanks
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9923
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8813
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.