Bitmap 2114 Microsoft Access doesn't support the format of the f Version: 2002 (10.0) XP

Hello All,

I have been trying to get what I thought was something simple.

I’m trying to copy a bitmap from one Image control to another below is my code and I know I don’t have to use the packString and unPackString in this example. In real life I need to. So I’m hoping that someone can show me the error of my ways so to speak.

My code is below

Thanks
Art


Option Compare Database
Option Explicit

Private Sub Command2_Click()
Dim bGIF1() As Byte
Dim bGIF2() As Byte
Dim strGif As String

On Error GoTo TrapError
bGIF1() = I1.Picture 'I1 is an Image control with an embedded bitmap image
' The Bitmap is C:\WINDOWS\Zapotec.bmp
packString bGIF1, strGif

unPackString strGif, bGIF2

Open "c:\ztest\xtest.gif" For Binary Access Write As #1 Len = UBound(bGIF2)
Put #1, 1, bGIF2
Close #1
'This is the line of code that generates teh error
i2.Picture = "c:\ztest\xtest.gif" 'I2 is another image contriol

'*************************************
' Error Number: 2114
' Error Description: Microsoft Access doesn't support the format of the file 'c:\ztest\xtest.gif,' so it can't load the picture.@@@1@@1
'*************************************


Exit Sub
TrapError:
Debug.Print Err.Number
Debug.Print Err.Description

End Sub


Sub unPackString(MyString As String, myByteArray() As Byte)

'Fills myByteArray with the bytes making up myString

ReDim myByteArray(Len(MyString))
Dim i As Integer

For i = 1 To Len(MyString)
myByteArray(i) = Asc(Mid$(MyString, i, 1))
Next

End Sub

Sub packString(myByteArray() As Byte, MyString As String)

'Fills myString with the bytes making up myByteArray
Dim i As Integer

MyString = ""
For i = 1 To UBound(myByteArray)
MyString = MyString & Chr$(myByteArray(i))
Next

End Sub
DeadcatsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jefftwilleyCommented:
>>Open "c:\ztest\xtest.gif

IT's the Gif format that Access is balking at. Is there a way you can save the Gif as a Jpeg or bitmap?

Is it your intention to have the Gif Move (animate) from within your object frame?
0
DeadcatsAuthor Commented:
I ave not lookied into converting it to a jpeg. It is not my goal to animate the graphic I need to store the gaphic and later produce it on a report. I do understand I can accomplish the same thing by storing it on the hard drive and storing a link to it. Unfortunattly that is not going to work for me do to the requirements. after it is a bitmap is there an easy way to convert it to a jpeg?
0
jefftwilleyCommented:
ok, but if we're dealing directly with your error...then that isn't dealing with an image as a stored object. That's assigning an image control an image on an underlying Drive. The reason THAT is failing, is because Access simply doesn't support the .GIF extension. Supported extensions are .BMP and .JPG

>>i2.Picture = "c:\ztest\xtest.gif" 'I2 is another image contriol
                                              ^^^
You need to NOT use gif image types.

IF you want to store images vs paths, then that's a whole different topic, and it's not what the code you pasted into your original Q does.
J
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

DeadcatsAuthor Commented:
Jeff

Thanks that clears things up for me greatly!!!

So what is capturing my image (actually a signature) generates a gif file. Is there an easy way to convert that to a jpg or bitmap and do the same string manipulation for storge?

Art
0
jefftwilleyCommented:
what program are you using to generate the signature images? IS there not a setting within that program to save the images as particular types? That would be the easiest...right at the source.
0
DeadcatsAuthor Commented:
I'm actually using the Tablet PC SDK to generate the signature, but as I understand it outputs just a gif.

Is there a way to convert the GIF to a jpeg with code that you know of?

I just realized I loaded a bitmap into image control i1 so I updated my test routine to try to load it as a bitmap and get another error. The code is below, any Ideas?

Art

Private Sub Command2_Click()
    Dim bGIF1() As Byte
    Dim bGIF2() As Byte
    Dim strGif As String
   
On Error GoTo TrapError
    bGIF1() = I1.Picture  'I1 is an Image control with an embedded bitmap image
                          ' The Bitmap is C:\WINDOWS\Zapotec.bmp
    packString bGIF1, strGif
   
    unPackString strGif, bGIF2
   
    Open "c:\ztest\xtest.bmp" For Binary Access Write As #1 Len = UBound(bGIF2)
    Put #1, 1, bGIF2
    Close #1
    'This is the line of code that generates teh error
    i2.PictureData = "c:\ztest\xtest.bmp"  'i2 is another image contriol
   
    '*************************************
    '  2192
    '  The bitmap you specified is not in a device-independent bitmap (.dib) format.@You tried to set the PictureData property of a form, report, button, or image control.@@1@@1
    '*************************************
   
   
    Exit Sub
TrapError:
    Debug.Print Err.Number
    Debug.Print Err.Description
   
End Sub
0
jefftwilleyCommented:
Try this for me.

Create a new blank form. Select your image object off the tool menu and try adding the c:\ztest\xtest.bmp file as it's source using the wizard. See if you get that error.
0
DeadcatsAuthor Commented:
Hey Jeff

I did wha tyou asked and I get the following message:

Microsoft Access doesn't support the format of the file 'C:\ztest\xtest.bmp,' so it can't load the picture.

I tried an image control and the picture property of the form.

Art
0
jefftwilleyCommented:
its obvious that that file isn't a .bmp file.

Did you just rename it from xtest.gif to xtest.bmp?
0
DeadcatsAuthor Commented:
Jeff it is a bitmap file I verified it.
0
jefftwilleyCommented:
Hey DC,
Well the method you're using to assign the object a file is correct. If you can't assign that particular file using the wizard, then code won't help either.
Are you able to take any .bmp file at all and assign it to an image frame on a blank form using the wizard?
0
DeadcatsAuthor Commented:
Jeff -
I have tried several bitmaps and I can not assign the any bitmap to an image frame.

Art

0
jefftwilleyCommented:
That's interesting....ok,

You never mentioned if this did or didn't work before...did it?

Do this on that test form you made. Go to design mode. From the menu select insert picture. it will let you browse for your .bmp file. See if it will let you create it that way.
J
0
DeadcatsAuthor Commented:
It will let me load it using the method that you asked me about. That is how I initially embedded it into i1.

if I run this it works fine:
     12.Picture = "C:\Windows\Zpotec.bmp

It is when I do the following. What I don't understand is I parse this to a byte array and then read it back and write the file what is different. I have checked the 2 byte arrays and everything matchs.

Private Sub Command2_Click()
    Dim bGIF1() As Byte
    Dim bGIF2() As Byte
    Dim strGif As String
   
On Error GoTo TrapError
    I1.Picture = "C:\WINDOWS\Zapotec.bmp"
    bGIF1() = I1.Picture  'I1 is an Image control with an embedded bitmap image
                         ' The Bitmap is C:\WINDOWS\Zapotec.bmp
     
    packString bGIF1, strGif
   
    unPackString strGif, bGIF2
   
    Open "c:\ztest\xtest.bmp" For Binary Access Write As #1 Len = UBound(bGIF2)
    Put #1, 1, bGIF2
    Close #1
    'This is the line of code that generates teh error
    i2.PictureData = "c:\ztest\xtest.bmp"  'i2 is another image contriol
   
    '*************************************
    '  2192
    '  The bitmap you specified is not in a device-independent bitmap (.dib) format.@You tried to set the PictureData property of a form, report, button, or image control.@@1@@1
    '*************************************
   
   
    Exit Sub
TrapError:
    Debug.Print Err.Number
    Debug.Print Err.Description
0
jefftwilleyCommented:
It is this part that you are using that has me confused.

Open "c:\ztest\xtest.bmp" For Binary Access Write As #1 Len = UBound(bGIF2)
    Put #1, 1, bGIF2
    Close #1
    'This is the line of code that generates teh error
    i2.PictureData = "c:\ztest\xtest.bmp"  'i2 is another image contriol

you're writing your Packed, Unpacked binary out as the BMP file replacing the original or so it seems...then trying to assign it as the image source.

Has this ever worked in your code?
J

PS. I've asked others to view the question so perhaps a new set of eyes and experience can help this question along.
0
Leigh PurvisDatabase DeveloperCommented:
You seem to be misusing the PictureData property.
The Picture property relates to a file you want to use.
You can use PictureData to directly assign the image data from one image control to another.
e.g.
Me.Image1.PictureData = Me.Image2.PictureData
0
DeadcatsAuthor Commented:
Jeff

That is just what I'm trying to do but am having no luck with it.
Would it help if I emailed you a copy of  file?

Art
0
DeadcatsAuthor Commented:
L

I understand what you are telling me but when I use the Image1.picture I get the following error:

2114
Microsoft Access doesn't support the format of the file 'c:\ztest\xtest.bmp,' so it can't load the picture.@@@1@@1
0
DeadcatsAuthor Commented:
Jeff

I have never gotten this to work and I ust don't understand why.

Art
0
Leigh PurvisDatabase DeveloperCommented:
Are you sure you're doing what it is that you're doing that I think you're doing that you think I said what you're doing?

If it's a bitmap - Access should load it (unless there's something fundamentally wrong - in which case it'll never be able to show it :-S)

So you would be doing something like
Me.Image2.Picture = "c:\ztest\xtest.bmp"
Me.Image1.PictureData = Me.Image2.PictureData

If you want to persist the data - you could look (as you are attempting) to extract the PictureData data to file and reload it... but why bother when the property is directly assignable?
0
jefftwilleyCommented:
I'm able to accomplish it with one simple step...

Private Sub CopyImg_Click()
Me.Img2.Picture = Me.Img1.Picture
End Sub


No binary exchange necessary...why did you want to use an array for this in the first place?
0
Leigh PurvisDatabase DeveloperCommented:
IMHO
Me.Img2.Picture = Me.Img1.Picture
would be wasteful of resources - you're asking the control Img2 to load the image with which Img1 has been loaded - from file again.
Assigning the PictureData assigns the binary value directly.  Which is always going to be more efficient.
(For example if the image isn't linked but embedded - the Picture data property could be out of date and misleading - leaving no way to load the image from file.  The PictureData property experiences no such limitation).
0
jefftwilleyCommented:
Glad you're here Leigh.
And I see where the ineffeciency would arise. Loading the PictureData accomplishes the same action, without having to reload the image. Learning.
J
0
DeadcatsAuthor Commented:
Jeff

I can get that to work and I have no problems with that.

My goal is to read the image into a byte array convert it to a string. After it is converted to a string I  need to store it in a memo field. This way I can retrieve it and dispaly the image on a report.
0
jefftwilleyCommented:
Looking through some older questions, Nico came up with a way to read bmp files up into a text or memo field that may assist your goal. It is a method using Blobs and although it may be something you're already familiar with...it is a good reference none the less.

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20378462.html
0
DeadcatsAuthor Commented:
Thanks Jeff I will take a look at it.

Art
0
Leigh PurvisDatabase DeveloperCommented:
Yeah BLOBs are the normal choice (the definitive work being done by EE's own Allen Warren http://www26.brinkster.com/alzowze/home.asp)

But since you've got it ready loaded - why are you not writing that PictureData data direct to the memo field?
I don't see the point of the file. :-S
0
DeadcatsAuthor Commented:
L

I believe I tried that and ran into some errors so went to a way I thought would work.

So if I may how do you suggest?

Art
0
Leigh PurvisDatabase DeveloperCommented:
What errors?  How big are these images you're saving?
How were you attempting to save them?
0
Leigh PurvisDatabase DeveloperCommented:
And I might as well mention it's *Alan* Warren - I'd actually typed Allen Browne because I'd not long since referred someone to his site lol  (I didn't delete enough of it though :-S)  Apologies to Alan.. I can spell honest. :-)

Art - any details on the problems you'd been having?
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Jeff ... sorry I chiming in a bit late here. I got the notify email, but I had issues getting online all afternoon with my Verizon wireless card (aghhhh).

I've looked over the thread a bit ... and I'm a bit confused re:

"The reason THAT is failing, is because Access simply doesn't support the .GIF extension."

I'm sure I'm missing something here, but I'm looking at a GIF image I just inserted on a Report and a Form. I can also load it from code, eg:

Me.Image13.Picture = "C:\Access2K3Clients\IRM\zzLogo\IRM LOGO BKGRND.gif"
And also this:

Me.Image15.Picture = Me.Image13.Picture  with no problem.

And these are definitely Gif's.

 So, when you say Access doesn't support a Gif ... what do you mean?

Also ... re:

"My goal is to read the image into a byte array convert it to a string. After it is converted to a string I  need to store it in a memo field. This way I can retrieve it and dispaly the image on a report."

Is there any chance that DBPix could help here:  http://www.ammara.com/   ??   Not exactly sure what Deadcats is trying to do, but DBPix does most of the work ... and has a pretty nice object model.  I've used it several times ... and the claims about virtually eliminating bloat are true.

mx


0
DeadcatsAuthor Commented:
Hello Everyone
I hope this will clarify everything. What I'm trying to do is to capture a signature and store that picture in a field in an mdb file, the retrieve the signature and print it on a report(customer invoice) when it is printed.

I can capture the signature with Microsoft's Tablet PC SDK 1.7 using the ink collection.  Saving the graphic(signature) is if a gif format.  I have concerns about just storing the gif as an OLEObject, namely datbase size. This is why I have saved it to a byte array and converted it to a string and plan on storing it in a memo field. I do understand that I can store the image as a file on the hard drive but the specs do not allow that.

As I said I can capture the signature I'm just stuck as to how to get it into and out of the database so it will work.

Thanks to everyone that has commented and I am going to impose again and ask how can I do this?

Art
0
Leigh PurvisDatabase DeveloperCommented:
Oh... It's YOU!  lol
Sorry - I never did get back to that question :-S
Always meant to - never did.  
(I can't use not being here as an excuse either - as you asked it across the road too ;-)

(I'd have liked to get more into the nitty gritty method of direct manipulation - but my investigations of the SDK you're using offers a shocking lack of documentation! :-S)
So are you saving your 3rd party control aquired image as a Gif file to disk?
Then what?
Loading it into a standard Image control?
It's a shame the external library doesn't support bitmaps.
Access stores all Images as bitmaps (well - before 2007 anyway).  So loading it in sees it converted (and I suspect not particularly efficiently).
So not matter how you store it - a converted Access image is bigger than it needs to be.
For example - save a JPEG to an OLE field (or dump it into a Memo field).
The db will bloat - the size of the JPEG - plus the size of the equivalent Bitmap - and *then* some!
Do the same with a Bitmap file - it'll essentially grow the size of the file.
(Which is pretty big anyway with a bitmap lol).
As I mentioned - Access 2007 handles this at last with built in filters for other graphics formats.

If you save the external file's binary data into a Memo (as you've been attempting) then you'll not end up with a file format that the Picture data can display.
If you're using an Image control as an intermediate and saving the binary picturedata into the memo and then attempting to reload it from there into an image - then that should work.

But you mentioned errors.
Can you detail the code you tried - and what errors there were?
0
jefftwilleyCommented:
mx,
>>"The reason THAT is failing, is because Access simply doesn't support the .GIF extension."

Brief moment of brain deadness I suppose. And I've since toyed with this some more, and I of course smacked my own forehead for putting poor DeadCats through all the initial pain.

As Leigh pointed out, I was not able to directly read in the graphic from my hard drive into an array and store it and then use that as the source for the Object, but that's about as far as I got on this one.

J
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
It's *OK* Jeff ... especially what you have just been through !!!!!!  
Anyway, my work is done here, lol.  

I would however offer deadcats the final suggestion to take a quick look at DBPix (free trial) and see if he could manipulate the object model to do what he needs ... read the sig and store it, etc.

mx
0
Leigh PurvisDatabase DeveloperCommented:
Access doesn't natively support GIFs - but with the proper converters installed it can and does.
(They're installed a vast majority of the time IME).
However the image you see on screen should be a DIB.  And you can indeed store that and reload it using the PictureData property.
Shock horror of course - Stephen Lebans has been there long before any of us and done sterling work.
Using a mthod in his clsPictureBox class you can save the image in an Image control (based on it's PictureData property) as a bitmap file (if you're so inclined).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.