Defeating the device-independent bitmap (.dib) format

John TsioumprisIT Supervisor
CERTIFIED EXPERT
I am passionate software developer and also a competent Systems Admin. I am open to interesting job opportunities worldwide.
Published:
Edited by: Andrew Leniart
A small Access Application that shows the handling of .jpg images to assign them to popular Microsoft Access Controls while stored in the Application itself in their original format.

If you are into the Microsoft Access development and you wanted to beautify your application with custom images it's almost certain that sometime you have encountered the dreaded :

Over time Access has “evolved” to be more forgiving on this subject by allowing Controls to be more versatile about accepting different format images than BMP (.dib) but this is not the case…it always comes a case that you need to assign on the fly some images to some controls to find out is impossible….well till now

I present the Dynamic Image Handler…a small demo Microsoft Access Application that will take care of this…

Just pick your .jpg …store it and use it, just let the code make the conversion from jpg.

So no more hunting down the paths where your images are stored…no more dreaded messages that the image you have stored in the database is NOT  compliant…just plain simple…pick your images…store them in your application with the known tiny size of .jpgs…most images presented in the application is just 2-4 kb size and just assign them to your controls…on the fly…no temp files... no extra controls to store the PictureData…no nothing

For start just open the Application :

Click the button: Simple Demo

And get to the form that shows 4 major controls (A Command Button, An Image, A Tab Control with 2 pages and a Toggle button)


On each case, you have a small button to pick your image…select it and let it show on the matching control.

If you have assigned images to all the controls you can click the Save Button 

and save them to the Table ImagesRepository

If you want to review them just hit the 2nd button: Browse

And review what you have already inserted


You want to insert images for your controls…as I did for everything that you see in this application.

Then it’s time for the 3rd button: Store Images for Application

You will be presented with this simple form

Nothing special …just type the Name of the Image and hit the Insert button…nothing more …nothing else.

Some small note here: The Check for OnlyForBMP is to store images for the Ribbon Controls…because I want to have them transparent I have to store them as BMPs…maybe in the future I could modify the code to take care of that but because its just for the Ribbon Controls and the sizes are small is wiser and easier to store them as BMP and get over it…as for the transparency if there is interest I will make a small article on this if there is interest.

The other two CheckBoxes just fill the empty space of not perfect images (size not multiple of 4) to instead of the default white to black or control (I tried to trick the Ribbon Controls but transparency is always nicer)

Well, that’s about it…Hit the Exit button to close the Application or if you want to know a little more about me there is a small About option underneath…

The application is completely unlocked so it's easy to check the underlying code and get a look at how the processing takes place.

I think the potential of this code is far greater…starting with the fact that you can store just about every image (jpg) taking advantage of its small size…and also because the resulting PictureData is just a Byte Array …you can dump the ImageList ActiveX Control and just store your images on a simple Collection.

Of course the more you use it the more uses you will find…

The application is here: DynamicImageHandler.accdb

It has been developed in Access 2019 x86 (32bit) and it should run on All 32bit Access from 2010 and after (on 2007 there is some issue on rendering the Page Control...probably there is a limitation because when I tried manually to assign an image it got distorted)



1
3,569 Views
John TsioumprisIT Supervisor
CERTIFIED EXPERT
I am passionate software developer and also a competent Systems Admin. I am open to interesting job opportunities worldwide.

Comments (5)

Mark EdwardsChief Technology Officer
CERTIFIED EXPERT

Commented:
Hey John:  What did I do wrong?  I downloaded your file, opened it, clicked on the … button for the "A command button" section, and the file picker kept graying out the Save button if I picked a.png file.  I clicked the Cancel button and got the attached error.

I can help you with setting up error handling in your apps.Error.PNG
John TsioumprisIT Supervisor
CERTIFIED EXPERT
Distinguished Expert 2020

Author

Commented:
It doesn't work with .pngs.. as i mentioned everything is about .jpgs & .bmps
Thanks for the error handling offer but i have a new version of this article that is also 64bit capable along with some extra features...but i am quite busy this period and i don't have the time to test it and release it
Mark EdwardsChief Technology Officer
CERTIFIED EXPERT

Commented:
ah, got it.  Thanks.
David Johnson, CDThe More I know, the more I don't know
CERTIFIED EXPERT
Most Valuable Expert 2023
Distinguished Expert 2023

Commented:
i have a new version of this article where is it john?
John TsioumprisIT Supervisor
CERTIFIED EXPERT
Distinguished Expert 2020

Author

Commented:
David is not yet ready... i am still on testing phase and lets say i have too much work to find the necessary time...

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.