Defeating the device-independent bitmap (.dib) format

Published on
10,698 Points
1 Endorsement
Last Modified:
John Tsioumpris
I am passionate software developer and also a competent Systems administrator.I enjoy learning new things and challenges...
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)

Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free