In this series we will try to develop kindly applications. In the beginning you and I try to develop it with our information. When I complete the first part I will share my experiences, information and source code. You can get help while this challenge from internet and if you stuck you can look my example up. However, if you try harder and harder to do it yourself, you can gain more and permanent experience. I will also direct you to necessary sources for doing this.
Challenge: Develop a program that create art with using different shapes, functions and color schemes by using user input to BMP image file.
Before starting:
This project is not suitable for beginner level coders. If you feel you are weak at programming first develop yourself with this sources and some challenges. (I will share some challenges with their solutions soon)
Some titles that you need to know (if you don't know some, do not worry you can handle them while challenge) :
- All basics
- OOP
- Vectors
- Algorithm logic
- File manipulations
1-) File Header (14 bytes):
- Signature (2 bytes): The first two bytes are 'B' and 'M' (ASCII values 66 and 77) to identify the file as a BMP.
- File Size (4 bytes): The size of the entire BMP file in bytes.
- Reserved (4 bytes): Reserved for future use.
- Data Offset (4 bytes): The offset, in bytes, from the beginning of the file to the bitmap image data.
- Header Size (4 bytes): The size of the header (always 40 bytes for the BITMAPINFOHEADER).
- Image Width (4 bytes): The width of the bitmap image in pixels.
- Image Height (4 bytes): The height of the bitmap image in pixels. Positive for bottom-up, negative for top-down.
- Number of Color Planes (2 bytes): Usually set to 1.
- Bits Per Pixel (2 bytes): The number of bits used to represent each pixel (e.g., 24 bits for RGB).
- Compression Method (4 bytes): The compression method used (usually 0 for no compression).
- Image Size (4 bytes): The size of the raw bitmap data (can be set to 0 for no compression).
- Horizontal Resolution (4 bytes): Pixels per meter (optional).
- Vertical Resolution (4 bytes): Pixels per meter (optional).
- Number of Colors in Palette (4 bytes): The number of colors in the color palette (0 for full color).
- Number of Important Colors (4 bytes): Usually set to 0.(This because Every color is important)
3-)Color Palette (Optional): For images with indexed color (e.g., 1-bit or 8-bit BMPs), there may be a color palette immediately following the DIB header. (We don't use it)
4-)Bitmap Data: The raw pixel data of the image, typically organized in rows from bottom to top, with each row aligned to a multiple of 4 bytes (padding bytes are added if necessary).
(Our main work on that area)
//Define structures
struct BMPFileHeader
{
char signature[2] = {'B', 'M'};
uint32_t filesize; //Calculate
uint16_t reserved1 = 0;
uint16_t reserved2 = 0;
uint32_t dataOffset; // Calculate
};
struct BMPDIBHeader
{
uint32_t DIBHeaderSize = 40;
uint32_t ImageWidth;
uint32_t ImageHeight;
uint16_t NumberOfColorPlanes = 1;
uint16_t BitsPerPixel = 24;
uint32_t CompressionMethod = 0;
uint32_t ImageSize; //Calculate
uint32_t HorizontalResolution = 0;
uint32_t VerticalResolution = 0;
uint32_t NumberOfColorsInPallette = 0;
uint32_t NumberOfImportantColors = 0;
};

Comments
Post a Comment