dcsimg
Results 1 to 1 of 1

Thread: [VB6] MapStitcher.cls - Create imagemaps from images

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,654

    [VB6] MapStitcher.cls - Create imagemaps from images

    Sometimes it can be handy to make use of the PictureClip control or similar approaches to grab and use small images "cut out" from a larger image set up in a grid layout. But usually we have separate images to work with, and stitching them together into a larger "imagemap" image can be tedious.

    MapStitcher.cls is a VB6 class that makes use of WIA 2.0 to create such "maps." A really simple thing but you might find it useful.


    Limitations

    Since WIA 2.0 only offers limited capabilities for handling transparency, this works best when you have images that make use of mask color transparency. If you give it source images with PNG or GIF transparency it can "stamp" these onto a backdrop making use of the transparency but there isn't any way to retrieve a composite image with any transparency itself.

    This isn't all bad, since so many VB6 controls and operations make use of mask color transparency anyway. But note that to be effective your source images should use the same mask color, and you'd want to set the composite image's backdrop color to match that.


    Demo

    I've attached the class in a demo Project "StitchMap."

    StitchMap loads the images that it finds in the directory "Samples" and assumes a magenta mask/backdrop color (255, 0, 255). It looks at the first loaded image and places its dimensions in pixels into the Cell width and Cell Height TextBoxes, and puts a 4 into the Cells per row TextBox. You can change those values.

    When you click the Stitch button it passes these values to MapStitcher, which creates a stitched image. The demo displays this:


    Name:  sshot1.png
Views: 597
Size:  14.0 KB

    Oops! One image got cut off.


    Name:  sshot2.png
Views: 562
Size:  14.5 KB

    Changed dimensions to match the large image


    Then you could click the Save as BMP button and it will save this to Stitched.bmp and reset.

    It also works with a longer list of input images, though this will run a little longer:

    Name:  sshot3.png
Views: 573
Size:  45.1 KB


    Summary

    Sometimes you need to create imagemaps from small images, but positioning them using Paint, etc. can be a pain.

    MapStitcher shows a way to do this more easily. You could wrap this in a program with more options: browse to the input folder, list the input files and their dimensions, a backdrop color-picker, save-as dialog, etc.

    You could also modify MapStitcher, replacing WIA 2.0 by GDI+ flat API calls to obtain more options such as saving the composite image as a PNG with a transparent backdrop.
    Attached Files Attached Files
    Last edited by dilettante; Mar 20th, 2016 at 02:16 PM. Reason: typo in title

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width