re-assemble images

mnorma12 used Ask the Experts™
Hello all, I just finished writing a program to download images tiles from terraserver (aerial photos) the next task at hand is to re-assemble these pictures and save them as a single jpeg/tiff/bmp whatever. So I guess my question is how can I merge multiple smaller jpegs into one large one?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The sinple answer is to load them then write code to "paste" them into a picturebox.  The tricky part is figuring out where in the picturebox to put them, which I'll leave to you at this point.

Assuming that you're putting a picture into "row 2, column 2" and each picture is 100x100 pixels:

1) Add a picturebox, picture1, to a form, form1
2) Set its ScaleMode to 3-pixels
3) In some sort of event (command button click?) add code like this:

Picture1.PaintPicture LoadPicture("Row2Col2.gif"), (intRow-1) * intWidth+1, (intCol-1) * intHeight+1', intWidth, intHeight', 0, 0, intOriginalCropWidth, intOriginalCropHeight

If you put this into a loop to read the files, you should be able to assemble the picture, then use the code below to save as a large bitmap:

SavePicture Picture1.Picture, "MyLargeTerraServerImage.bmp"


Great post I will most likely give you the points, but I need to know how to do this in an access api (VBA). Any ideas on this.

Also, if I decide to go with a vb api instead, I am guessing it will choke when I try to load in a couple hundred (or even thousand) pictures (the bmp would be absolutely huge!). Any ideas on how to compress it into a jpeg?

I haven't tried using Access for something like this, but I'm sure that you would simply do the same in a module, then push the results into the form.  However, since Access forms and components are a bit different from VB forms, I'm not sure that things will work exactly the same.

>Any ideas on how to compress it into a jpeg?
I've seen this question several times here in EE so you might want to check the archives.  To convert from .bmp to anything else, you'll need a converter, and none are built into VB.  I'd probably recommend using a better tool such as Photoshop, PaintShopPro, or even MS Paint to do this if it will not be an on-going effort.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


VBA is very similar to VB, my problem stems from not being able to use a picture box. The only options I have are an image or an unbound object frame. I don't think I can use either of these (please correct me if I am wrong). If I could get this working with bitmaps I will consider it a great success.

Since none of these things seem to support the PaintPicture method, I can see two possibilities:

1) Use the BitBlt API and apply the image to the Image control's picture property

2) Use "real" VB to create a picturebox control as a new OCX so you can import it into Access's forms.

I tried the second one with a control I had created a while ago and it seems to work (although it's missing the necessary properties for your needs.)  If you have access to a compilable version of VB, just create a user-form with a picturebox, then run the wizard to transfer all picturebox properties, methods and events to the new user control (maybe called AccessPictureBox), then compile it into an OCX.  You'll also want to add other nice things like the control's resize event automatically sizing the picturebox.

If you need additional help with the user control, let me know.  Or it you need help with the BitBlt API (which does the same as PaintPicture) let me know and I'll profile it for you.


Would there be a way to organize the images in the picture box through xml.

Currently, as the files are downloaded the names are loaded into an xml table which is later processed through an xsl template to display the seamless table of images in a browser.

If I could use the same xml file to load the images into the picturebox or into the bitblt control it might save me some additional coding.

Also, I Am not familiar with the functions of bitblt what could I do with it? If you could provide a little sample coding on how to create a row or two of images that'd be great.

Private Declare Function BitBlt& Lib "GDI32" _
  (ByVal hDestDC As Long, _
   ByVal lDestX As Long, _
   ByVal lDestY As Long, _
   ByVal lDestWidth As Long, _
   ByVal lDestHeight As Long, _
   ByVal hSrcDC As Long, _
   ByVal lSrcX As Long, _
   ByVal lSrcY As Long, _
   ByVal lRasterOp As Long)

    lRetValue = BitBlt(picHide.hDC, 0, 0, Me.ScaleWidth, Me.ScaleHeight, Me.hDC, 0, 0, vbSrcCopy)

This will require that you have a control with a "D"evice "C"ontext, and I'm not sure it Access offers that.

I haven't tried XML yet.

Do you really need to save the assembled image?  It's not enough to just tile image controls on demand?


I am very happy to be able to re-assemble the tiles, but if I want to use them in a program like ArcView having a few thousand small tiles to deal with is quite annoying.

I was hoping I could get away with doing this in access, but it is sounding more and more like I may have to break down and do it all in Visual Basic. I may try to make a visual basic executable that will take the xml file that the access program creates and use it to re-assemble the images in a picture box.

Thanks for all of your help 'rspahitz' I'll use the code you provided above, and award you the points.


Sometimes I'm surprised at how limited the Access codeset is!  It's so powerful and yet doesn't have some of the basic things that programmers use.  This was certainly a learning experience for me too, so thanks again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial