Saving a Region

Regions can be saved inside TIFF files. Whenever you save a bitmap containing a region as a TIFF file format, the region is also saved.

When you save a bitmap with a region as a CUR or ICO file, the pixels inside the region are considered to belong to the icon/cursor data. The pixels outside the region are considered transparent. If you save a bitmap without a region as a CUR or ICO file, the whole bitmap will be considered icon/cursor data. In this case, you will get a square icon or cursor.

If you save a bitmap with a region as any other file format, the region will be lost. If you want to preserve the region, you can:

image\sqrblit.gif Save it to a 1-bit mask using the CreateMaskFromRgn method and save the mask as a separate file. When you load the bitmap, you should load the mask bitmap and set the region using the SetRgnFromMask method.

image\sqrblit.gif Save it to the alpha information in a 16/32-bit image. You would convert the region to a 1-bit mask using the CreateMaskFromRgn method, after which you would set the mask to the alpha channel using the BitmapAlpha property. While loading, you would get the alpha bitmap with the BitmapAlpha property, convert it to 1-bit if necessary and then set the region with the SetRgnFromMask method.

Related topics:

image\sqrblit.gif Creating and Using a Bitmap Region

image\sqrblit.gif Raster Images: Where the Region Preempts the Bitmap

image\sqrblit.gif Raster Images: Methods That Transform the Region and the Bitmap