473,386 Members | 1,721 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,386 software developers and data experts.

Another "A generic error occured in GDI+" Error

Hello All,

I have some pictureboxes on a VB.NET form that are linked to an AccessDB. If
the user wishes to open or edit an image, I need to save the image in the
picturebox to a temp file, then open that file in whatever viewer/editor is
the default for the users system. I tried to do
picturebox1.image.save(filename), which results in "A Generic error occured
in GDI+".

However, if I use an unbound picturebox, do a
picturebox2.image=image.fromfile(filename1), then do a
picturebox2.image.save(filename), it works fine.

My GDI+ error is not being caused by a permissions problem, as I'm using the
same folder for the bound and unbound picturebox. It seems that it has
something to do with the way the picturebox retrieves the image information
from the database. Is there a way around this?

Regards and TIA,
Lee
Nov 21 '05 #1
13 4620
It might be worth trying the same experiment on an image not held in Access.
It stores a 78 byte header in front of the image information. Not sure if
this is causing the problem, but hopefully narrows down the cause.

"lgbjr" <lg***@online.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hello All,

I have some pictureboxes on a VB.NET form that are linked to an AccessDB.
If the user wishes to open or edit an image, I need to save the image in
the picturebox to a temp file, then open that file in whatever
viewer/editor is the default for the users system. I tried to do
picturebox1.image.save(filename), which results in "A Generic error
occured in GDI+".

However, if I use an unbound picturebox, do a
picturebox2.image=image.fromfile(filename1), then do a
picturebox2.image.save(filename), it works fine.

My GDI+ error is not being caused by a permissions problem, as I'm using
the same folder for the bound and unbound picturebox. It seems that it has
something to do with the way the picturebox retrieves the image
information from the database. Is there a way around this?

Regards and TIA,
Lee

Nov 21 '05 #2
Well, that's what I was thinking, since the unbound picturebox can save an
image to a file, but the bound picturebox (to Access) can not. However, in
the past few minutes (after my original post), I found that there are
certain images stored in the AccessDB that will save without the GDI+ error.

Comparing an image that will save from the picture box to one that won't:

No error image:
JPG 150x150 (a small image)
Error Image:
JPG 1024x768 (a big image)

I'm going to create some different versions of the image that produces the
GDI+ error and see if I can figure out what the limitation is (maybe pixel
HxW, maybe file size, maybe aspect, maybe color depth, etc.). Just an FYI,
all of the images in the AccessDB, except one, cause the GDI+ error.

If anyone has run into this before, please let me know (as I don't want to
waste too much time experimenting if there's already a known solution!)

"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ya***************@newsfe1-gui.ntli.net...
It might be worth trying the same experiment on an image not held in
Access. It stores a 78 byte header in front of the image information. Not
sure if this is causing the problem, but hopefully narrows down the cause.

"lgbjr" <lg***@online.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hello All,

I have some pictureboxes on a VB.NET form that are linked to an AccessDB.
If the user wishes to open or edit an image, I need to save the image in
the picturebox to a temp file, then open that file in whatever
viewer/editor is the default for the users system. I tried to do
picturebox1.image.save(filename), which results in "A Generic error
occured in GDI+".

However, if I use an unbound picturebox, do a
picturebox2.image=image.fromfile(filename1), then do a
picturebox2.image.save(filename), it works fine.

My GDI+ error is not being caused by a permissions problem, as I'm using
the same folder for the bound and unbound picturebox. It seems that it
has something to do with the way the picturebox retrieves the image
information from the database. Is there a way around this?

Regards and TIA,
Lee


Nov 21 '05 #3
You could use Access to "launch" the image ie, double click the field. Then,
using whatever viewer is launched (probably iexplore) save the file to a new
location.
Go back into the Access table and add a new row using the new file.
The reason for doing this is it takes a known good image that can be
displayed (because you see it in IExplore), that is saved to disk by a
separate application, and added to a new row in Access, possibly ruling out
anything strange with the record.

"lgbjr" <lg***@online.nospam> wrote in message
news:OI**************@TK2MSFTNGP10.phx.gbl...
Well, that's what I was thinking, since the unbound picturebox can save an
image to a file, but the bound picturebox (to Access) can not. However, in
the past few minutes (after my original post), I found that there are
certain images stored in the AccessDB that will save without the GDI+
error.

Comparing an image that will save from the picture box to one that won't:

No error image:
JPG 150x150 (a small image)
Error Image:
JPG 1024x768 (a big image)

I'm going to create some different versions of the image that produces the
GDI+ error and see if I can figure out what the limitation is (maybe pixel
HxW, maybe file size, maybe aspect, maybe color depth, etc.). Just an FYI,
all of the images in the AccessDB, except one, cause the GDI+ error.

If anyone has run into this before, please let me know (as I don't want to
waste too much time experimenting if there's already a known solution!)

"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ya***************@newsfe1-gui.ntli.net...
It might be worth trying the same experiment on an image not held in
Access. It stores a 78 byte header in front of the image information. Not
sure if this is causing the problem, but hopefully narrows down the
cause.

"lgbjr" <lg***@online.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hello All,

I have some pictureboxes on a VB.NET form that are linked to an
AccessDB. If the user wishes to open or edit an image, I need to save
the image in the picturebox to a temp file, then open that file in
whatever viewer/editor is the default for the users system. I tried to
do picturebox1.image.save(filename), which results in "A Generic error
occured in GDI+".

However, if I use an unbound picturebox, do a
picturebox2.image=image.fromfile(filename1), then do a
picturebox2.image.save(filename), it works fine.

My GDI+ error is not being caused by a permissions problem, as I'm using
the same folder for the bound and unbound picturebox. It seems that it
has something to do with the way the picturebox retrieves the image
information from the database. Is there a way around this?

Regards and TIA,
Lee



Nov 21 '05 #4
Found an article that may help rule out any permission properties . .

http://groups.google.co.uk/groups?hl...3DN%26tab%3Dwg


"lgbjr" <lg***@online.nospam> wrote in message
news:OI**************@TK2MSFTNGP10.phx.gbl...
Well, that's what I was thinking, since the unbound picturebox can save an
image to a file, but the bound picturebox (to Access) can not. However, in
the past few minutes (after my original post), I found that there are
certain images stored in the AccessDB that will save without the GDI+
error.

Comparing an image that will save from the picture box to one that won't:

No error image:
JPG 150x150 (a small image)
Error Image:
JPG 1024x768 (a big image)

I'm going to create some different versions of the image that produces the
GDI+ error and see if I can figure out what the limitation is (maybe pixel
HxW, maybe file size, maybe aspect, maybe color depth, etc.). Just an FYI,
all of the images in the AccessDB, except one, cause the GDI+ error.

If anyone has run into this before, please let me know (as I don't want to
waste too much time experimenting if there's already a known solution!)

"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ya***************@newsfe1-gui.ntli.net...
It might be worth trying the same experiment on an image not held in
Access. It stores a 78 byte header in front of the image information. Not
sure if this is causing the problem, but hopefully narrows down the
cause.

"lgbjr" <lg***@online.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hello All,

I have some pictureboxes on a VB.NET form that are linked to an
AccessDB. If the user wishes to open or edit an image, I need to save
the image in the picturebox to a temp file, then open that file in
whatever viewer/editor is the default for the users system. I tried to
do picturebox1.image.save(filename), which results in "A Generic error
occured in GDI+".

However, if I use an unbound picturebox, do a
picturebox2.image=image.fromfile(filename1), then do a
picturebox2.image.save(filename), it works fine.

My GDI+ error is not being caused by a permissions problem, as I'm using
the same folder for the bound and unbound picturebox. It seems that it
has something to do with the way the picturebox retrieves the image
information from the database. Is there a way around this?

Regards and TIA,
Lee



Nov 21 '05 #5
"lgbjr" <lg***@online.nospam> schrieb:
Well, that's what I was thinking, since the unbound picturebox can save an
image to a file, but the bound picturebox (to Access) can not. However, in
the past few minutes (after my original post), I found that there are
certain images stored in the AccessDB that will save without the GDI+
error.

Comparing an image that will save from the picture box to one that won't:

No error image:
JPG 150x150 (a small image)
Error Image:
JPG 1024x768 (a big image)


I suggest to check if the data read from the database is the same data that
is stored in the image file that has been inserted into the database.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6
Hmmm, Very Good Point!! This is what I've found. First, the Pic filed type
in the AccessDB is OLE Object. I have a button on my VB.NET form that calls
an OpenFile Dialog for the user to select a picture (now limited via a
filter to JPGs). The JPG file selected in the dialog is used to display the
image in the picturebox (picturebox.image=image.fromfile(dialog.filename)

I never actually looked back at the AccessDB, simply because as I selected
new records in my VB form, the pictures that were added were always shown in
the pictureboxes correctly.

Well, here's the situation. If I look at the AccessDB, the Pic field does
not contain an OLE object (package). It says Long binary Data, and I can't
view the image. If I right click on a PIC cell and insert a JPG (from file),
the cell shows as a package (and I can double-click to open the image).
However, if I now go back to my VB.NET form, the records that have a package
in the pic field will not display the picture in the picture box.

Still, some of the pictures that are saved to the AccessDB via the
picturebox (Long Binary Data) can be saved back to disk via
picturebox.image.save, some can not. So, I think I might have two problems.
First is how to save an image in a picturebox back to the AccessDB as a
package and/or how to view a picture stored as a package in the AccessDB in
a picturebox. Maybe, if I can fix this issue, the GDI+ issue will go away.

Regards,
Lee

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"lgbjr" <lg***@online.nospam> schrieb:
Well, that's what I was thinking, since the unbound picturebox can save
an image to a file, but the bound picturebox (to Access) can not.
However, in the past few minutes (after my original post), I found that
there are certain images stored in the AccessDB that will save without
the GDI+ error.

Comparing an image that will save from the picture box to one that won't:

No error image:
JPG 150x150 (a small image)
Error Image:
JPG 1024x768 (a big image)


I suggest to check if the data read from the database is the same data
that is stored in the image file that has been inserted into the database.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7
Hi

I think we need to stored the picture in access as the binary data without
the ole header.
While the picture added by access will have the oleheader which is not
supported in OLEDB provide of ADO.NET, so we need to stripe it off to
retrieve the data directly.
Here is a google link for your reference.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #8
Peter,

OK, that sounds like a good suggestion! Can you post the link you mentioned.

Thanks
Lee

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:p8**************@TK2MSFTNGXA02.phx.gbl...
Hi

I think we need to stored the picture in access as the binary data without
the ole header.
While the picture added by access will have the oleheader which is not
supported in OLEDB provide of ADO.NET, so we need to stripe it off to
retrieve the data directly.
Here is a google link for your reference.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #9
Hi Lee,

Sorry for that.
Here is the link.
http://groups.google.com/groups?hl=z...4-43,GGLD:en&t
hreadm=uAQhoo05EHA.2680%40cpmsftngxa10.phx.gbl&rnu m=1&prev=/groups%3Fq%3Dv-k
evy%2Bole%2Bheader%26hl%3Dzh-CN%26lr%3D%26rls%3DGGLD,GGLD:2004-43,GGLD:en%26
selm%3DuAQhoo05EHA.2680%2540cpmsftngxa10.phx.gbl%2 6rnum%3D1

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #10
Peter,

for some reason, I always have trouble when someone sends me a google link.
I can never get the page to load. If you can tell me the string you searched
for and what result you selected, I can just do my own search from here.

Thanks
Lee

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:5p*************@TK2MSFTNGXA02.phx.gbl...
Hi Lee,

Sorry for that.
Here is the link.
http://groups.google.com/groups?hl=z...4-43,GGLD:en&t
hreadm=uAQhoo05EHA.2680%40cpmsftngxa10.phx.gbl&rnu m=1&prev=/groups%3Fq%3Dv-k
evy%2Bole%2Bheader%26hl%3Dzh-CN%26lr%3D%26rls%3DGGLD,GGLD:2004-43,GGLD:en%26
selm%3DuAQhoo05EHA.2680%2540cpmsftngxa10.phx.gbl%2 6rnum%3D1

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #11
Hi

Ok, I think you may just search the string below in the groups.google.com
"Error " Invalid Parameter Used" when I try to display an image"

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #12
Peter,

I found a solution to my GDI+ problem! finally! Instead of trying to
retrieve the image from the picturebox, I'm going back to the AccessDB using
an OLEDBDataReader to get the data from the OLE Object field, and then using
a BinaryWriter to write the data to a file. Works perfectly.

I think the problem is not with the picturebox, or the AccessDB, but with
the dataset that is created from the OLEDataAdapter. for an Ole Object
field, the Schema type is set to Base64Binary. This works fine for
displaying the image in a picturebox. But, in reality, an Ole Object field
in the AccessDB is Base128Binary.

I'd like to, some day, write a new type for the dataset schema that is
Base128Binary, but for now, retrieving the image directly from the Access
table is working.

thanks for all of your help!!!

Regards,
Lee

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:T1**************@TK2MSFTNGXA02.phx.gbl...
Hi

Ok, I think you may just search the string below in the groups.google.com
"Error " Invalid Parameter Used" when I try to display an image"

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #13
Hi

I am glad that your project has worked.
Cheers!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #14

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

Similar topics

4
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following error: A generic error occurred in GDI+....
1
by: Vicente Nicolau | last post by:
hello, I have a problem when I preview or print a document in an ISO A0. I have an application which load an 10x10 image (bmp or jpg) and spread it in the A0 paper. When I make the print...
2
by: Alphonse Giambrone | last post by:
I am currently reading 'Programming The Web with Visual Basic .NET' and have so far found it to be excellent. Downloaded all the code from Apress and working in chapter 4, I get the error shown...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
0
by: nor | last post by:
Hi, I've application to capture video of image and grab the still image. It runs well untill I put loop to regrab the still images many times automatically.. and the error (generic error occured...
2
by: labby | last post by:
I've application to capture video of image and grab the still image. It runs well untill I put loop to regrab the still images many times automatically.. and the error (generic error occured GDI+)...
14
by: James Wong | last post by:
Hi everybody, I'm facing a serious trouble relating to GDI+ generic error. The error message is "A Generic error occured in GDI+" and the following information is stored in Excepton object:...
0
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have a bitmap which I have retreived through the WebBrowser DrawToBitmap method into a Bitmap. When I try to save the bitmap I get "ExternalException occurred A generic error occurred in...
0
by: Adnan Chaudhry | last post by:
Hi I'm trying to open, edit and save an animated gif. When saving frame 2 - I get the following error. A generic error occured in GDI+ when i reach the following step. img.SaveAdd(img2,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.