
BMP转换为MIF的工具。
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
This program, originally developed by a student in the ECE241 course, was designed to convert BMP images into MIF files, specifically for use with the Quartus II tool. Recent modifications have enabled compatibility with the new VGA controller utilized on the DE2 development board.
To utilize this converter, please follow these steps:
1. Create an image using a program such as Microsoft Paint. The image should be 160 pixels wide and 120 pixels high, and it must utilize 24-bit color information.
2. Subsequently, invert the created image vertically and save it as a BMP file (e.g., foo.bmp).
3. Execute the converter by providing the name of your BMP file as a command-line argument – for example, “bmp2mif foo.bmp”.
4. The program will generate two output files: “image.colour.mif” and “image.mono.mif”. “image.colour.mif” contains 8-bit color data derived from your original BMP file, representing an image with dimensions of n x m pixels and a 3-bit depth per pixel; while “image.mono.mif” presents a black-and-white representation of the same image, utilizing 1 bit to represent each pixels intensity (either black or white). You can modify the filenames of these generated files after creation but ensure they retain the .mif extension convention..
5. Copy the appropriate MIF file into the directory where your design is located and incorporate it into your project’s source code..
6. Adjust the `BACKGROUND_IMAGE` parameter within your VgaAdapter configuration to specify which MIF file should be used for displaying images..
7. Ensure that the `COLOR_CHANNEL_DEPTH` parameter is set to 1 when working with “image.colour.mif”.
The source code includes header files for standard input/output (`stdio.h`) and general utilities (`stdlib.h`). It defines custom functions like `FLIP_INT` and `FLIP_SHORT` for manipulating integer values within memory buffers to accommodate potential differences in data representation across operating systems (particularly Windows). The `faprint` function facilitates printing formatted data to both console output streams (for human readability) and binary output streams (for writing directly to the MIF files). The main function handles command-line argument parsing, error checking during file opening, BMP header parsing using `fread`, conversion logic including flipping byte order using defined macros, generating colour channel data in binary format suitable for inclusion in .mif files along with width & height parameters based on input bmp file information then writing this data sequentially into both .mif files based on whether its colour or monochrome representation.
全部评论 (0)


