473,799 Members | 3,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Image at runtime causes exception

Hi,

I am adding an new picbox and animated gif to it at runtime
Dim img As Image = Image.FromFile( Application.Sta rtupPath & "\animation.gif ")
With pic_Wait
.Location = New Point(300, 250)
.Width = 72
.Height = 101
.BackColor = Color.Transpare nt
.BorderStyle = BorderStyle.Non e
.Image = img
End With

When I run this code it exceptions out with a general GDI+ error.

Help please! :)

Cheers
Adam

Nov 21 '05 #1
7 1685
Hi,

It might be because of the backcolor of the picture box being
transparent. Try it with out it.
Ken
----------------
"Adam Maltby" <ad***@frfl.co. uk> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

I am adding an new picbox and animated gif to it at runtime
Dim img As Image = Image.FromFile( Application.Sta rtupPath &
"\animation.gif ")
With pic_Wait
.Location = New Point(300, 250)
.Width = 72
.Height = 101
.BackColor = Color.Transpare nt
.BorderStyle = BorderStyle.Non e
.Image = img
End With

When I run this code it exceptions out with a general GDI+ error.

Help please! :)

Cheers
Adam
Nov 21 '05 #2
Hi,

It fails even if I take out backcolor.
It always fails where the image is specified be it whether i do it by putting the image file in a dim and passing that to .image or if i remove the dim and specify directly at .image

Cheers
Adam

Nov 21 '05 #3
I had a similar problem with a splash screen that didn't want to get the
image correctly and used this to correct it:
Private Sub Splash_Load(ByV al sender As Object, ByVal e As System.EventArg s)
Handles MyBase.Load

Me.BackgroundIm age = Image.FromFile( mypath() + "\Flowers\Splas h.jpg")

Me.Height = Me.BackgroundIm age.Height

Me.Width = Me.BackgroundIm age.Width

End Sub

Private Function mypath() As String

Return _

Path.GetDirecto ryName([Assembly].GetExecutingAs sembly().Locati on)

End Function

I tried to use Application.Sta rtupPath and it would give problems on
different machines. This function
eliminated the problem.
Hope it at least gives you another thing to try.
james


"Adam Maltby" <ad***@frfl.co. uk> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

I am adding an new picbox and animated gif to it at runtime
Dim img As Image = Image.FromFile( Application.Sta rtupPath &
"\animation.gif ")
With pic_Wait
.Location = New Point(300, 250)
.Width = 72
.Height = 101
.BackColor = Color.Transpare nt
.BorderStyle = BorderStyle.Non e
.Image = img
End With

When I run this code it exceptions out with a general GDI+ error.

Help please! :)

Cheers
Adam

--------------------------------------------------------------------------------
Hi,

I am adding an new picbox and animated gif to it at runtime
Dim img As Image = Image.FromFile( Application.Sta rtupPath &
"\animation.gif ")
With pic_Wait
.Location = New Point(300, 250)
.Width = 72
.Height = 101
.BackColor = Color.Transpare nt
.BorderStyle = BorderStyle.Non e
.Image = img
End With

When I run this code it exceptions out with a general GDI+ error.

Help please! :)

Cheers
Adam
Nov 21 '05 #4
thanks - i'll give it a shot.

Nov 21 '05 #5
I'm afraid that did not work either.......

Nov 21 '05 #6
I know that was not all of your code for loading the image. But, I did not
see where you assigned "img" to your picturebox so that it could actually
display it. That itself would cause a general error in GDI+.
Maybe, you should post more of the code you are using.
james

"Adam Maltby" <ad***@frfl.co. uk> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I'm afraid that did not work either.......

--------------------------------------------------------------------------------
I'm afraid that did not work either.......
Nov 21 '05 #7
It was on the first pose in the line above the With entry.

But for reference it was:

Dim img As Image = Image.FromFile( Application.Sta rtupPath & "\animation.gif ")
Cheers
Adam

Nov 21 '05 #8

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

Similar topics

5
15949
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived from an Abstract class, I do not believe that this class object is causing me my problem. Below is that message I have posted before to other groups. Question:
4
7974
by: Simon Verona | last post by:
I'm using wia in a vb.net project to capture images from a scanner.. This works fine. However, I want to control the way that images are scanned - ie B+W, Greyscale and resolution etc, but can't work out how to. My code for scanning is below (sorry it's a bit messy - it's been chopped and changed around a lot)... There seems to be very little documentation on WIA, can anybody help me with this ??? Code is :
26
2825
by: Simon Jefferies | last post by:
Hello, I am trying to add an item to a checked list box, like: clbList.Items.add("Hello",true) I get an error back: Run-time exception thrown: System.ArgumentOutOfRangeException - Specified argument was out of the range of valid values. Parameter name: '-1' is not a
3
2828
by: Scott | last post by:
Hello, I am running into a problem with my code and can't seem to figure out the solution. I know it has to do with the pciture box control and unloading the image inthe picture box but I can't seem to figure out the correct way to "unload" the file. I have a simple form with a picture box and a button. I am using dir() to get all the the .tif files and display them in the pciture box. Each time the button it pressed it displays the...
0
1602
by: anandv81 | last post by:
Hi, I encountered a strange problem while working on an application, the problem goes like this. I am generating a few textboxes at runtime at the server side and added to a placeholder, a value is set for each of the textboxes. There is a button that causes the page to be posted back and the texboxes are re-rendered. When the textboxes are re-rendered the values are reset and these texboxes are again added to the placeholder. The names
2
2029
by: eric.dennison | last post by:
In the sample below: testClass is derived from object. We can cast object to testClass, no problem We can cast testClass to object no problem Compiler is ok with cast object to testClass but fails at runtime. Why?
5
4467
by: DBC User | last post by:
I have a situation, where I need to add 4 or 5 data files (they change every time I build) in my project during build time and somehow I need a way to access these files during runtime. So I have 2 questions 1. Is it possible to identify all the files in the resource file during runtime by name of the file? 2. Is it possible to add files to a project at build time to make an exe with those files? Thanks.
3
1325
by: =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post by:
I recently raninto major problems when I added the Exception namespace to the Project which has my DBML file attached to it. Once I renamed all the Exceptions instances to Syste.Exception the project would not recoginize any assembly which had been added to the project, even know they were all there, this happened to the designer.cs file that is attached to the dbml file. I have no clue as to why this is the problem. -- Alexander L....
2
1596
by: =?Utf-8?B?SmVmZlAtPg==?= | last post by:
I want to retrieve an image file (TIF) convert it to a bmp file and enable sizing. I know how to do the converting & sizing part, and store any atributes to file location in the webconfig, what I don't know is how to get the image file. The only way that I've got it working was to Impersonate a user login at the other server.
0
9543
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
10488
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
10257
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
10029
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
7567
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
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
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.