OpenTTD Source 20260218-master-g2123fca5ea
bmp.cpp File Reference

Read and write support for bmps. More...

#include "stdafx.h"
#include "random_access_file_type.h"
#include "bmp.h"
#include "core/bitmath_func.hpp"
#include "safeguards.h"

Go to the source code of this file.

Functions

static bool BmpRead1 (RandomAccessFile &file, BmpInfo &info, BmpData &data)
 Reads a 1 bpp uncompressed bitmap.
static bool BmpRead4 (RandomAccessFile &file, BmpInfo &info, BmpData &data)
 Reads a 4 bpp uncompressed bitmap.
static bool BmpRead4Rle (RandomAccessFile &file, BmpInfo &info, BmpData &data)
 Reads a 4-bit RLE compressed bitmap.
static bool BmpRead8 (RandomAccessFile &file, BmpInfo &info, BmpData &data)
 Reads a 8 bpp bitmap.
static bool BmpRead8Rle (RandomAccessFile &file, BmpInfo &info, BmpData &data)
 Reads a 8-bit RLE compressed bpp bitmap.
static bool BmpRead24 (RandomAccessFile &file, BmpInfo &info, BmpData &data)
 Reads a 24 bpp uncompressed bitmap.
bool BmpReadHeader (RandomAccessFile &file, BmpInfo &info, BmpData &data)
 Reads bitmap headers, and palette (if any).
bool BmpReadBitmap (RandomAccessFile &file, BmpInfo &info, BmpData &data)
 Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Detailed Description

Read and write support for bmps.

Definition in file bmp.cpp.

Function Documentation

◆ BmpRead1()

bool BmpRead1 ( RandomAccessFile & file,
BmpInfo & info,
BmpData & data )
inlinestatic

Reads a 1 bpp uncompressed bitmap.

The bitmap is converted to a 8 bpp bitmap. Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Parameters
fileThe file to read.
infoThe already read medata.
dataThe buffer to read the image into.
Returns
true iff the file could be read without problems.

Definition at line 21 of file bmp.cpp.

References RandomAccessFile::AtEndOfFile(), GB(), BmpInfo::height, RandomAccessFile::ReadByte(), RandomAccessFile::SkipBytes(), and BmpInfo::width.

Referenced by BmpReadBitmap().

◆ BmpRead24()

bool BmpRead24 ( RandomAccessFile & file,
BmpInfo & info,
BmpData & data )
inlinestatic

Reads a 24 bpp uncompressed bitmap.

Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Parameters
fileThe file to read.
infoThe already read medata.
dataThe buffer to read the image into.
Returns
true iff the file could be read without problems.

Definition at line 217 of file bmp.cpp.

References RandomAccessFile::AtEndOfFile(), GB(), BmpInfo::height, RandomAccessFile::ReadByte(), RandomAccessFile::SkipBytes(), and BmpInfo::width.

Referenced by BmpReadBitmap().

◆ BmpRead4()

bool BmpRead4 ( RandomAccessFile & file,
BmpInfo & info,
BmpData & data )
inlinestatic

Reads a 4 bpp uncompressed bitmap.

The bitmap is converted to a 8 bpp bitmap. Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Parameters
fileThe file to read.
infoThe already read medata.
dataThe buffer to read the image into.
Returns
true iff the file could be read without problems.

Definition at line 45 of file bmp.cpp.

References RandomAccessFile::AtEndOfFile(), GB(), BmpInfo::height, RandomAccessFile::ReadByte(), RandomAccessFile::SkipBytes(), and BmpInfo::width.

Referenced by BmpReadBitmap().

◆ BmpRead4Rle()

bool BmpRead4Rle ( RandomAccessFile & file,
BmpInfo & info,
BmpData & data )
inlinestatic

Reads a 4-bit RLE compressed bitmap.

The bitmap is converted to a 8 bpp bitmap. Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Parameters
fileThe file to read.
infoThe already read medata.
dataThe buffer to read the image into.
Returns
true iff the file could be read without problems.

Definition at line 71 of file bmp.cpp.

References RandomAccessFile::AtEndOfFile(), GB(), BmpInfo::height, RandomAccessFile::ReadByte(), RandomAccessFile::SkipBytes(), and BmpInfo::width.

Referenced by BmpReadBitmap().

◆ BmpRead8()

bool BmpRead8 ( RandomAccessFile & file,
BmpInfo & info,
BmpData & data )
inlinestatic

Reads a 8 bpp bitmap.

Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Parameters
fileThe file to read.
infoThe already read medata.
dataThe buffer to read the image into.
Returns
true iff the file could be read without problems.

Definition at line 143 of file bmp.cpp.

References RandomAccessFile::AtEndOfFile(), GB(), BmpInfo::height, RandomAccessFile::ReadByte(), RandomAccessFile::SkipBytes(), and BmpInfo::width.

Referenced by BmpReadBitmap().

◆ BmpRead8Rle()

bool BmpRead8Rle ( RandomAccessFile & file,
BmpInfo & info,
BmpData & data )
inlinestatic

Reads a 8-bit RLE compressed bpp bitmap.

Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Parameters
fileThe file to read.
infoThe already read medata.
dataThe buffer to read the image into.
Returns
true iff the file could be read without problems.

Definition at line 157 of file bmp.cpp.

References RandomAccessFile::AtEndOfFile(), BmpInfo::height, RandomAccessFile::ReadByte(), RandomAccessFile::SkipBytes(), and BmpInfo::width.

Referenced by BmpReadBitmap().

◆ BmpReadBitmap()

bool BmpReadBitmap ( RandomAccessFile & file,
BmpInfo & info,
BmpData & data )

Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Parameters
fileThe file to read.
infoThe already read medata.
dataThe buffer to read the image into.
Returns
true iff the file could be read without problems.

Definition at line 313 of file bmp.cpp.

References BmpRead1(), BmpRead24(), BmpRead4(), BmpRead4Rle(), BmpRead8(), BmpRead8Rle(), BmpInfo::bpp, BmpInfo::compression, BmpInfo::height, BmpInfo::offset, RandomAccessFile::SeekTo(), and BmpInfo::width.

Referenced by ReadHeightmapBMP().

◆ BmpReadHeader()

bool BmpReadHeader ( RandomAccessFile & file,
BmpInfo & info,
BmpData & data )

Reads bitmap headers, and palette (if any).

Reads the bitmap 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps.

Parameters
fileThe file to read.
infoThe already read medata.
dataThe buffer to read the image into.
Returns
true iff the file could be read without problems.

Definition at line 236 of file bmp.cpp.

References BmpInfo::bpp, BmpInfo::compression, RandomAccessFile::GetPos(), BmpInfo::height, BmpInfo::offset, BmpInfo::os2_bmp, BmpInfo::palette_size, RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), RandomAccessFile::ReadWord(), RandomAccessFile::SkipBytes(), and BmpInfo::width.

Referenced by ReadHeightmapBMP().