Solved

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

Posted on 2007-03-27
36
1,699 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:Deadcats
  • 14
  • 12
  • 8
  • +1
36 Comments
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18805383
>>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
 

Author Comment

by:Deadcats
ID: 18807132
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18808600
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
 

Author Comment

by:Deadcats
ID: 18809478
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18809569
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
 

Author Comment

by:Deadcats
ID: 18809877
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18809971
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
 

Author Comment

by:Deadcats
ID: 18810107
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18812017
its obvious that that file isn't a .bmp file.

Did you just rename it from xtest.gif to xtest.bmp?
0
 

Author Comment

by:Deadcats
ID: 18812421
Jeff it is a bitmap file I verified it.
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18812476
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
 

Author Comment

by:Deadcats
ID: 18815105
Jeff -
I have tried several bitmaps and I can not assign the any bitmap to an image frame.

Art

0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18816422
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
 

Author Comment

by:Deadcats
ID: 18816662
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18816935
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
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 18816974
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
 

Author Comment

by:Deadcats
ID: 18817207
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
 

Author Comment

by:Deadcats
ID: 18817256
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 

Author Comment

by:Deadcats
ID: 18817267
Jeff

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

Art
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 18817308
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18817367
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
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 18817399
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18817433
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
 

Author Comment

by:Deadcats
ID: 18817437
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18817621
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
 

Author Comment

by:Deadcats
ID: 18817640
Thanks Jeff I will take a look at it.

Art
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 18817737
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
 

Author Comment

by:Deadcats
ID: 18817765
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
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 18817841
What errors?  How big are these images you're saving?
How were you attempting to save them?
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 18819986
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
 
LVL 75
ID: 18821701
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
 

Author Comment

by:Deadcats
ID: 18822605
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
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 18822906
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
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18824089
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
 
LVL 75
ID: 18824454
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
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 500 total points
ID: 18825363
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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now