473,903 Members | 4,301 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 #1
18 1874
PS: picImage is a PictureBox.

"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 #2
"John" <jo**@nospam.in fovis.co.uk> wrote in news:OxEaex3kDH A.1284
@TK2MSFTNGP09.p hx.gbl:
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?


I presume from the fact that you aren't indicating that the compiler is
failing that you really mean

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");

(the @ tells the compiler not to interpret the '\' characters), OR

z = Image.FromFile( "c:\\temp\\imag e.gif");

-mbray
Nov 20 '05 #3
Evening John,

Put a breakpoint on the Image = z line and check the value of z. You'll
find that it's Nothing.

z.FromFile() is calling a <shared> method. It's the same as calling
Bitmap.FromFile (..). In other words it doesn't (can't) change z.

What you need is either:
Dim z As System.Drawing. Bitmap
z = Bitmap.FromFile ("c:\temp\image .gif")
or simply
Dim z As New System.Drawing. Bitmap ("c:\temp\image .gif")

Regards,
Fergus
Nov 20 '05 #4
Howdy Michael,

It's in VB so the syntax is fine, but it's true that the result should be
assigned to z.

Regards,
Fergus
Nov 20 '05 #5
"Fergus Cooney" <fi******@tesco .net> wrote in
news:u7******** ******@TK2MSFTN GP09.phx.gbl:
It's in VB so the syntax is fine, but it's true that the result
should be
assigned to z.


Yeah I realized that and knocked on my head a few times after I saw your
original reply. This is why I think we should just get rid of VB
altogether. *ducks* (just kidding, of course.)

-mbray
Nov 20 '05 #6
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 #7
Thanks. That worked.

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.

Thanks

Regards
"Fergus Cooney" <fi******@tesco .net> wrote in message
news:eh******** ******@tk2msftn gp13.phx.gbl...
Evening John,

Put a breakpoint on the Image = z line and check the value of z. You'll find that it's Nothing.

z.FromFile() is calling a <shared> method. It's the same as calling
Bitmap.FromFile (..). In other words it doesn't (can't) change z.

What you need is either:
Dim z As System.Drawing. Bitmap
z = Bitmap.FromFile ("c:\temp\image .gif")
or simply
Dim z As New System.Drawing. Bitmap ("c:\temp\image .gif")

Regards,
Fergus

Nov 20 '05 #8
* "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 #9
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
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" )


Use this instead: 'z = Image.FromFile( ...)'

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #10

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

Similar topics

4
7341
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
3489
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
5235
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
5836
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
2165
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
2688
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
4241
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
1692
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
2201
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
7767
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
10004
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
9853
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
11293
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
10882
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...
1
10989
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
10504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8057
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
5899
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
6100
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.