Up | TOC | Index | |||||
<< 7 Included Tools | < 8.45 Graphics - Cross Platform | Up: 8 API Reference | 8.47 Euphoria Information > | 9 Release Notes >> |
8.46 Graphics - Image Routines
8.46.0.1 graphics_point
include std/image.e namespace image public type graphics_point(object p)
8.46.1 Bitmap handling
8.46.1.1 read_bitmap
include std/image.e namespace image public function read_bitmap(sequence file_name)
Read a bitmap (.BMP) file into a 2-d sequence of sequences (image)
Parameters:
- file_name : a sequence, the path to a .bmp file to read from. The extension is not assumed if missing.
Returns:
An object, on success, a sequence of the form {palette,image}. On failure, an error code is returned.
Comments:
In the returned value, the first element is a list of mixtures, each of which defines a color, and the second, a list of point rows. Each pixel in a row is represented by its color index.
The file should be in the bitmap format. The most common variations of the format are supported.
Bitmaps of 2, 4, 16 or 256 colors are supported. If the file is not in a good format, an error code (atom) is returned instead
public constant BMP_OPEN_FAILED = 1, BMP_UNEXPECTED_EOF = 2, BMP_UNSUPPORTED_FORMAT = 3
You can create your own bitmap picture files using Windows Paintbrush and many other graphics programs. You can then incorporate these pictures into your Euphoria programs.
Example 1:
x = read_bitmap("c:\\windows\\arcade.bmp")
Note:
double backslash needed to get single backslash in a string
See Also:
8.46.1.2 save_bitmap
include std/image.e namespace image public function save_bitmap(two_seq palette_n_image, sequence file_name)
Create a .BMP bitmap file, given a palette and a 2-d sequence of sequences of colors.
Parameters:
- palette_n_image : a {palette, image} pair, like read_bitmap() returns
- file_name : a sequence, the name of the file to save to.
Returns:
An integer, 0 on success.
Comments:
This routine does the opposite of read_bitmap(). The first element of palette_n_image is a sequence of mixtures defining each color in the bitmap. The second element is a sequence of sequences of colors. The inner sequences must have the same length.
The result will be one of the following codes:
public constant BMP_SUCCESS = 0, BMP_OPEN_FAILED = 1, BMP_INVALID_MODE = 4 -- invalid graphics mode -- or invalid argument
save_bitmap() produces bitmaps of 2, 4, 16, or 256 colors and these can all be read with read_bitmap(). Windows Paintbrush and some other tools do not support 4-color bitmaps.
Example 1:
code = save_bitmap({paletteData, imageData}, "c:\\example\\a1.bmp")
See Also: