#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "errors.h"
Go to the source code of this file.
|
| struct Bmp * | Bmp_destruct (struct Bmp *this) |
| | It destructs a managing object for one image.
|
| |
| unsigned int | Bmp_getWidth (struct Bmp *this) |
| |
| unsigned int | Bmp_getHeight (struct Bmp *this) |
| | It supplies the height of an image.
|
| |
| unsigned long | Bmp_getLength (struct Bmp *this) |
| | It supplies the number of pixels.
|
| |
| void | Bmp_getPixelOfRaster (struct Bmp *this, int horizontal, int vertical, unsigned char *red, unsigned char *green, unsigned char *blue, int *error) |
| | It supplies three colors of a pixel when the horizontal and vertical positions of a raster are provided by the caller.
|
| |
| void | Bmp_getPixelOfLine (struct Bmp *this, int index, unsigned char *red, unsigned char *green, unsigned char *blue, int *error) |
| | It supplies three colors of a pixel when the horizontal and vertical positions of a raster are provided by the caller.
|
| |
| struct Bmp * | Bmp_readFile (const char *filename, int *error) |
| | It loads an image file with the bmp format into memory.
|
| |
| void | Bmp_writeFile (struct Bmp *this, const char *filename, int *error) |
| | It writes an image in a file in bmp format.
|
| |
◆ FILE_HEADER_LENGTH
| #define FILE_HEADER_LENGTH 14 |
Definition at line 8 of file Bmp.c.
◆ INFO_HEADER_LENGTH
| #define INFO_HEADER_LENGTH 40 |
Definition at line 9 of file Bmp.c.
◆ PAD_LENGTH
Definition at line 10 of file Bmp.c.
◆ RGB_COLOR_LENGTH
| #define RGB_COLOR_LENGTH 3 |
Definition at line 7 of file Bmp.c.
◆ Bmp_destruct()
| struct Bmp * Bmp_destruct |
( |
struct Bmp * |
this | ) |
|
It destructs a managing object for one image.
- Parameters
-
| this | a managing object for one image |
Definition at line 22 of file Bmp.c.
◆ Bmp_getHeight()
| unsigned int Bmp_getHeight |
( |
struct Bmp * |
this | ) |
|
It supplies the height of an image.
- Parameters
-
| this | a managing object for one image |
Definition at line 39 of file Bmp.c.
◆ Bmp_getLength()
| unsigned long Bmp_getLength |
( |
struct Bmp * |
this | ) |
|
It supplies the number of pixels.
It is used to extract individual pixels in a loop.
- Returns
- the number of pixels in the image.
- Parameters
-
| this | a managing object for one image |
Definition at line 44 of file Bmp.c.
◆ Bmp_getPixelOfLine()
| void Bmp_getPixelOfLine |
( |
struct Bmp * |
this, |
|
|
int |
index, |
|
|
unsigned char * |
red, |
|
|
unsigned char * |
green, |
|
|
unsigned char * |
blue, |
|
|
int * |
error |
|
) |
| |
It supplies three colors of a pixel when the horizontal and vertical positions of a raster are provided by the caller.
- Parameters
-
| this | a managing object for one image |
| index | the pixel position in a line (0 is top left), it cannot be equal or exceed the length of an image |
| red | red value (from 0 to 255) |
| green | green value (from 0 to 255) |
| blue | blue value (from 0 to 255) |
| error | error tracking (0 means no error) |
Definition at line 58 of file Bmp.c.
◆ Bmp_getPixelOfRaster()
| void Bmp_getPixelOfRaster |
( |
struct Bmp * |
this, |
|
|
int |
horizontal, |
|
|
int |
vertical, |
|
|
unsigned char * |
red, |
|
|
unsigned char * |
green, |
|
|
unsigned char * |
blue, |
|
|
int * |
error |
|
) |
| |
It supplies three colors of a pixel when the horizontal and vertical positions of a raster are provided by the caller.
- Parameters
-
| this | a managing object for one image |
| horizontal | the vertical pixel position starting from above (0 is top), it cannot be equal or exceed the image width |
| vertical | the horizontal position of a pixel counted from the left side of the screen from the point of view of the user (0 is left), it cannot be equal or exceed the image height |
| red | red value (from 0 to 255) |
| green | green value (from 0 to 255) |
| blue | blue value (from 0 to 255) |
| error | error tracking (0 means no error) |
Definition at line 49 of file Bmp.c.
◆ Bmp_getWidth()
| unsigned int Bmp_getWidth |
( |
struct Bmp * |
this | ) |
|
- Parameters
-
| this | a managing object for one image |
Definition at line 34 of file Bmp.c.
◆ Bmp_readFile()
| struct Bmp * Bmp_readFile |
( |
const char * |
filename, |
|
|
int * |
error |
|
) |
| |
It loads an image file with the bmp format into memory.
The order is RGBRGBRGB from top left to bottom right, without any padding. The RGBA format with alpha channel for opacity is not supported.
One pixel image reserves 54 bytes for headers. Color space information must not be added to the headers.
> hexdump -C bmps/one_pixel_all_channels_different.bmp
00000000 42 4d 3a 00 00 00 00 00 00 00 36 00 00 00 28 00 |BM:.......6...(.|
00000010 00 00 01 00 00 00 01 00 00 00 01 00 18 00 00 00 |................|
00000020 00 00 04 00 00 00 23 2e 00 00 23 2e 00 00 00 00 |......#...#.....|
00000030 00 00 00 00 00 00 56 34 12 00 |......V4..|
-------- -- -- -- -- -- -- 56 34 12 -- here: blue 56 + green 34 + red 12
- Returns
- a managing object for one image
- Parameters
-
| filename | a path to a file |
| error | error tracking (0 means no error) |
Definition at line 65 of file Bmp.c.
◆ Bmp_writeFile()
| void Bmp_writeFile |
( |
struct Bmp * |
this, |
|
|
const char * |
filename, |
|
|
int * |
error |
|
) |
| |
It writes an image in a file in bmp format.
- Parameters
-
| this | a managing object for one image |
| filename | a path to a file |
| error | error tracking (0 means no error) |
Definition at line 242 of file Bmp.c.