473,796 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying image

Hi

I am trying to display an image in a dialog using the following code;

Dim frm As New frmImage
Dim z As System.Drawing. Bitmap

z.FromFile("c:\ temp\image.gif" )
frm.picImage.Im age = z
frm.ShowDialog( )
frm.Dispose()

Trouble is that no image appears in the dialog. What am I doing wrong?

Thanks

Regards
Nov 20 '05
18 1864
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
Anyway to zoom the image if it is too big to fit in picturebox's current
size? Ideally I would like a zoom level that a user can set, otherwise
whatever is possible.


\\\
Dim bmp As New Bitmap( _
"C:\Lagoon1024x 768.bmp" _
)
Dim bmp2 As New Bitmap( _
bmp.Width * 0.1, _
bmp.Height * 0.1, _
Imaging.PixelFo rmat.Format24bp pRgb _
)
Dim g As Graphics = Graphics.FromIm age(bmp2)

' Select/change interpolation mode here.
g.Interpolation Mode = _
Drawing.Drawing 2D.Interpolatio nMode.HighQuali tyBicubic

' Draw image using specified interpolation mode.
g.DrawImage(bmp , 0, 0, bmp2.Width, bmp2.Height)
g.Dispose()

Me.PictureBox1. Image = bmp2
bmp2.Save("C:\f oo.bmp")
..
..
..
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #11
* Michael Bray <mb************ *******@SkPiAlM l.ctiusa.com> scripsit:
z = Image.FromFile( "c:\temp\image. gif");

but there is another error. I think you are having a problem with your
backslashes in the filename... In general, you should always check a
variable before you use it. I would put money of the supposition that 'z'
is null after the call to FromFile(). To FIX the problem replace the line
with either:

z = Image.FromFile( @"c:\temp\image .gif");


Not in VB.NET... We don't need the '@' prefix.

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #12
Michael: This means war. You'd better duck, or Me and Herfried will hunt you
down.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflecti on Master "

==== Converting to 2002 ====
Remove inline declarations
"Fergus Cooney" <fi******@tesco .net> wrote in message
news:um******** ******@tk2msftn gp13.phx.gbl...
Hi Michael,

ROFL. Many a serious word spoken in jest.

Presumably you're from a framework group, so welcome to this glimpse of languages.vb. ;-)

Regards,
Fergus

Nov 20 '05 #13
* "Tom Spink" <th**********@n tlworld.com> scripsit:
Michael: This means war. You'd better duck, or Me and Herfried will hunt you
down.


VB.NET rules.

;-)))

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #14
These functions may be useful if you're still having trouble.

'VB.NET

Private Function ImageFromAbsolu tePath(ByVal absolutePath As String) As
System.Drawing. Bitmap
Dim img As System.Drawing. Bitmap = New
System.Drawing. Bitmap(absolute Path)
Return img
End Function

Private Function ImageFromRelati vePath(ByVal relativePath As String) As
System.Drawing. Bitmap
Dim executingPath As String =
System.IO.Path. GetDirectoryNam e(System.Reflec tion.Assembly.G etExecutingAsse m
bly.Location)
Dim img As System.Drawing. Bitmap = New
System.Drawing. Bitmap(String.C oncat(executing Path, "/", relativePath))
Return img
End Function

Private Function ImageFromEmbedd ed(ByVal embeddedPath As String) As
System.Drawing. Bitmap
Dim imageStream As System.IO.Strea m =
System.Reflecti on.Assembly.Get ExecutingAssemb ly.GetManifestR esourceStream(e m
beddedPath)
Dim img As System.Drawing. Bitmap = New
System.Drawing. Bitmap(imageStr eam)
Return img
End Function
//C#
private System.Drawing. Bitmap ImageFromAbsolu tePath(string absolutePath)
{
System.Drawing. Bitmap img = new System.Drawing. Bitmap(absolute Path);
return img;
}

private System.Drawing. Bitmap ImageFromRelati vePath(string relativePath)
{
string executingPath =
System.IO.Path. GetDirectoryNam e(System.Reflec tion.Assembly.G etExecutingAsse m
bly().Location) ;
System.Drawing. Bitmap img = new
System.Drawing. Bitmap(string.C oncat(executing Path, "/", relativePath));
return img;
}

private System.Drawing. Bitmap ImageFromEmbedd ed(string embeddedPath) {
System.IO.Strea m imageStream =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetManifes tResourceStream (
embeddedPath);
System.Drawing. Bitmap img = new System.Drawing. Bitmap(imageStr eam);
return img;
}
}

--
Justin Weinberg

Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at www.mrgsoft.com
"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:Ox******** ******@TK2MSFTN GP09.phx.gbl...
Hi

I am trying to display an image in a dialog using the following code;

Dim frm As New frmImage
Dim z As System.Drawing. Bitmap

z.FromFile("c:\ temp\image.gif" )
frm.picImage.Im age = z
frm.ShowDialog( )
frm.Dispose()

Trouble is that no image appears in the dialog. What am I doing wrong?

Thanks

Regards

Nov 20 '05 #15
Definitely. Thanks. Now I am trying to zoom/scale the image, when it is too
large to fit in the control/form.

Thanks

Regards
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:bm******** ****@ID-208219.news.uni-berlin.de...
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
PS: picImage is a PictureBox.


Problem solved?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #16
Thanks. I will try this.

Regards
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:bm******** ****@ID-208219.news.uni-berlin.de...
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
Anyway to zoom the image if it is too big to fit in picturebox's current
size? Ideally I would like a zoom level that a user can set, otherwise
whatever is possible.


\\\
Dim bmp As New Bitmap( _
"C:\Lagoon1024x 768.bmp" _
)
Dim bmp2 As New Bitmap( _
bmp.Width * 0.1, _
bmp.Height * 0.1, _
Imaging.PixelFo rmat.Format24bp pRgb _
)
Dim g As Graphics = Graphics.FromIm age(bmp2)

' Select/change interpolation mode here.
g.Interpolation Mode = _
Drawing.Drawing 2D.Interpolatio nMode.HighQuali tyBicubic

' Draw image using specified interpolation mode.
g.DrawImage(bmp , 0, 0, bmp2.Width, bmp2.Height)
g.Dispose()

Me.PictureBox1. Image = bmp2
bmp2.Save("C:\f oo.bmp")
.
.
.
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #17
The GDI+ FAQ has an article on displaying images in a given rectangle while
maintaining the aspect ratio of the original.

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Blog http://bobpowelldotnet.blogspot.com

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:OG******** ******@tk2msftn gp13.phx.gbl...
Definitely. Thanks. Now I am trying to zoom/scale the image, when it is too large to fit in the control/form.

Thanks

Regards
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:bm******** ****@ID-208219.news.uni-berlin.de...
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
PS: picImage is a PictureBox.


Problem solved?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>


Nov 20 '05 #18
Howdy Bob,

I've been a-browsing over the last few days- nice site you've got - lots
of goodies. ;-)

Regards,
Fergus
Nov 20 '05 #19

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

Similar topics

4
7337
by: Gregory | last post by:
Hello, I've managed to build two web pages, one that can display images with associated text data in a table, and one that can resize and display images without the text. I'd like to resize the images as I go, without writing them to disk on the server. Do I need to prepare all of the resized images before I display the data from the select (which is put into an array by php). How can I display a resized image in a table, without writing...
3
3485
by: Dalan | last post by:
At first I was not certain what could cause Access 97 from displaying most jpeg images, but not all. After further testing, it seemed that all original images of less than 275 pixels per inch or less would display, but those close to 300 pixels/inch or greater would not (MS Access cannot recognize the file format xxx.jpg). The larger, original images were scanned and saved as .bmp (at 300 dpi producing a 15MB file). Then the images were...
2
5230
by: marvin | last post by:
Hi, I am trying to display images in a repeater from a SQL database and do some transformations on the image prior to displaying them (such as thumbnail with a shadow). The problem is I can't seem to get the data passed to the handler. The following is the code that I have so far. In the ViewPics.aspx file I have...
3
5828
by: CD | last post by:
An application is logging faxes sent in SQL2000 image column type. I have found code on the net but what it is doing is prompting to save to local which is fine for single page image. Not good for multiple page faxes. I have not been able to locate an example to load in the browser or how to handle multiple image in the one column. 1) Ideally it would be nice to display back in the browser since some may be multiple images. I am not...
5
2159
by: ljuljacka | last post by:
I'm trying to display resized images. Locations of images are fetched from database. The problem is that with the following code, I get only the first image displayed: <?php header('Content-type: image/jpeg'); $link = mysql_connect('localhost', 'root', ''); if (!$link) {
4
2683
by: redpears007 | last post by:
Hi Again, Throwing this one out to you again as i am not getting anywhere and can find little to no information out there. I am currently displaying images (Jpegs) in access via the routine set up in the article http://support.microsoft.com/kb/285820/en-us. It works fine if the image is under 1000x1000 pixels. It is set up so the user can double click to open the image in its host application.
1
4225
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly? http://geekarama.co.uk/new_home.html here is the code for new_home.html and following that the CSS...
4
1688
by: shahidrasul | last post by:
i display a pic on picture box and then i want to display another pic after some seconds but problem is that first image is not displaying only display 2nd image 1... display first picture from database such as pbThumbImage.Image = new Bitmap(new MemoryStream(objEmployee.Picture)); 2... and then get the reference of current main thread Thread main = Thread.CurrentThread; Thread.Sleep(5000);
6
2197
by: Jeff | last post by:
hi asp.net 2.0 I have a image (.jpeg) stored in sql server 2005 and now I want to display it on a webpage. So I created a webpage (Image.aspx) which just writes the buffer data to the Response object. On Default.aspx I use this Image.aspx for displaying the image, but no image
3
7746
by: mvijayrkumar | last post by:
Hi to all.... Guys pls help me..... I have an image issue in RLDC while hosting my project on server.The image displays or works fine with the local system.But when hosted on server,both the images(One coming from DataSet and another from my project image folder) not displaying. Both images are having Type property External and the Values are given correspondingly.ie The One coming from Image Folder;using the Report Parameter ,the...
0
9673
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
9525
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10452
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...
0
10221
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9050
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
7546
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
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
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.