How to put one image over another in a form

this is a very basic and easy stuff.

the image that will stay on the top must have some kind of transparency set. it is recommended that you use a bmp of 24bits. vfp will automatically convert the white parts of the image into transpaent, like in the picture below, if you set the "backstyle" property of the image object to 0 - transparent. don't forget to set the picture to "bring to front" in the "layout" toolbar.

the 1st form shows the 2 images separated, but with opaque backgrounds. then, in the 2nd, i set the background to transparent, then dropped a part of the image for you to see how it is done. you can get more information in this post too:

bmps with transparent backgrounds http://weblogs.foxite.com/vfpimaging/archive/2007/10/24/5190.aspx

another good way is to use pngs, that support alpha (transparencies), but the most recommneded, and best supported by vfp is the use of bmps, as shown.


update - oct 30, 2007

bernard bout remembers that "also note that all white areas of an image will become transparent. for instance in the second image in cesars post the form background is visible through the eye of the brazilian man. if this is not what you want then you must "mask" out the white parts of the bitmap that you want to be not transparent.  
just open the image and paint the white areas you want to keep black. the image should be the same size. paint all the other parts white and save it as a bmp but with a .msk extension. vfp will automatically use this file to "mask" out the white areas from being transparent."

for this case, i usually edit the image, and change the pure rgb "whites" - rgb(255,255,255) that i want to keep to another close white, such as rgb(254,254,254) nobody will notice the difference and it works very nice, with the advantage of not needing to create an extra image file.

anyway, if you still prefer to create a mask, choose to create a 1bpp monochrome image format. usually people save in "24bits" mode. but as msk pictures are only b&w, monochrome will bring the possibility to have the smallest image file size. comparing to a monochrome image, the 24bpp image will be 24 times bigger in size.

in mspaint, for example, choose, in "saveas..."


other important notes about msk files:

in help for pictureval:

"you cannot specify a mask (msk) file with the pictureval property. if you are using bmp images and want a mask, you should use the picture property instead. you can also use a different image format such as gif which has transparency defined within the image."

how to: enhance control display a very nice explanation about msk files


1 comment:

  1. Este articulo esta traducido al español en PortalFox:

    -- Cómo poner una imagen sobre otra en un formulario --