|
|
|
|
|
|
|
Sponsored By


|
|
|
|
|
|

|
|
|
|
|
|
|
Efika 5200B Project
 |
Reggae on Efika
in category Multimedia proposed by Grzegorz Kraszewski on 21st February 2006 (accepted on 20th March 2006)
|
|
|
|
|
|
Blog Entry
|
|
|
|
|
|
|
Image background problem
posted by Grzegorz Kraszewski on 22nd July 2007
GIF format, amongst other features, has a possibility to define a background color used in case, where logical screen is bigger than following images. The definition sounds quite simple "it is used on area not covered by image[s]". Implementing this is very simple for non-transparent images, the logical screen is just filled with background color, then sub-images are stacked on it.
Things complicate with transparency. Looking again into GIF89a spec, pixels with transparent color are simply not rendered. Simple? Does not. Let's use dnetc logo as an example.
The right half of image is transparent. But if I fill the whole logical screen with background (index 255, black) and then impose the image, transparent areas will not replace the background ("transparent pixels are not rendered"...). Then it is obvious that coverage from background definition does not mean pixel coverage, but sub-image coverage. It is very simple in the case of this image: there is one subimage covering all the logical screen, so there is just no background. It may happen however that logical screen is not 100% covered by following subimages, and the shape of not covered area is highly irregular.
My solution to this problem is as follows: I will not fill the logical screen with background color, but with 100% transparent pixels. Then I impose all subimages, and at last fill all uncovered areas (if any) with background color. To determine the uncovered area, I will have to make boolean operations on rectangular areas. Fortunately a set of functions for this is already present in graphics.library, so I will use it.
|
|
|
|
|
|