471,578 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,578 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 4475
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Michael Kennedy [UB] | last post: by
1 post views Thread by Vicente Nicolau | last post: by
2 posts views Thread by Alphonse Giambrone | last post: by
14 posts views Thread by James Wong | last post: by
reply views Thread by =?Utf-8?B?Sm9hY2hpbQ==?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Vinnie | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

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.