Foxite.COM Community Weblog

Foxite.COM Community Weblog - free weblog service for the Visual FoxPro Community.
Welcome to Foxite.COM Community Weblog Sign in | Join | Help
in
Home Blogs Forum Photos Forum Archives

VFP IMAGING



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/cesarchalom/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

 

Published Tuesday, October 30, 2007 11:44 AM by cesarchalom
Filed Under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Cesar Chalom said:

The function below converts any button image to a BMP to be used in VFP forms.
There are lots of cool...
November 14, 2007 3:51 PM
 

Luis Maria Guayan said:

Este articulo esta traducido al español en PortalFox:

-- Cómo poner una imagen sobre otra en un formulario --
http://www.portalfox.com/article.php?sid=2548
January 14, 2008 1:48 AM

What do you think?

(required) 
(optional)
(required)