Programmer's Reference

Copying images from a drawable

A rectangular area of a drawable can be retrieved as an image using the getDeviceIndependentImage: method of CgDrawable. This is primarily useful for taking snapshots of the screen or specific windows. It can also be used, with putDeviceIndependentImage:, to stretch an area of a drawable.

The following example gets the contents of the entire default screen as an image:

| screen rect image |
screen := CgScreen default.
rect := 0 @ 0 extent: screen width @ screen height.
image := screen rootWindow getDeviceIndependentImage: rect


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]