This little unit offers the functionality to create a screen shot of the
current screen. The screen shot is created as a compressed PNG file with
either 256 colors or with 16 gray scales. Of course using the gray scale
mode looks not as good, but the resulting image file size is usually
smaller.
The screen shot is taken in true color and then reduced to either 256 colors
or to 16 gray scales. In order to reduce the image to 256 colors a heavily
optimized algorythm is used which makes sure that all important colors are
contained in the resulting image. In most cases the resulting image
virtually looks exactly like the original true color image. The reduction to
gray scales uses Floyd-Steinberg dithering to get a good result.
The function "CreateScreenShotPng" does all the work. It returns a binary
string, which you can directly save into a PNG file. You can tell the
function to either create a 256 colored or gray scale image. Alternatively
you can also tell it to try to keep the image size under a specific
threshold. In that case 256 colors are used if the resulting image stays
under the specified size limit. Otherwise a gray scale image is returned.
The reason for this option is that screen shots of full screen apps often
can be reduced that well that there's no difference between 256 colors and
gray scales. But when huge bitmaps are contained in the screen shot the
colored image takes more space than the gray scale image. By specifying a
image file size threshold you can get nice colored images whenever the
compression works well and small gray scale images, when colored images
would take too much space.
|
type
TScreenShotType = (st256Colors, st16Grays, st50kb, st100kb, st200kb, st300kb);
function CreateScreenShotPng (screenShotType: TScreenShotType) : string;
|
|