上传者: u012551136
|
上传时间: 2021-11-15 21:54:08
|
文件大小: 27KB
|
文件类型: -
Bmp To Mif 转换器
// (karimov 2005)
// This program was originnaly written by one of the ECE241 students to convert an image
// supplied in a BMP file into an MIF file format for use with Quartus II.
//
// This program has recently been modified to work with the new VGA controller used with the DE2
// board.
//
// What to do:
// 1. Create an image in Microsoft paint (or other program). The image must be 160 pixels wide, 120 pixels high and
// use 24-bits to represent colour information.
// 2. Once you create the image you need, flip it up-side down. Then save the BMP file. (example: foo.bmp)
// 3. Run this converter in command prompt using the name of the BMP file you created as a command-line parameter.
// For example:
// bmp2mif foo.bmp
// 4. The program generates two files:
// image.colour.mif - an MIF file with 3 bits colour information obtained from the BMP file you supplied
// image.mono.mif - an MIF file containing 1 bit of colour for every pixel on the screen. The dot will either be
// black or white.
// You can change the file names once they are created, but they should still have the .mif extension.
//
// 5. Copy the proper MIF file to the directory where your design is located and include it in your project.
// 6. Change the BACKGROUND_IMAGE parameter of the VgaAdapter to indicate your MIF file.
// 7. The COLOR_CHANNEL_DEPTH parameter must be set to 1 to work with the image.colour.mif file.
#include
#include
#define FLIP_INT(c) ((c >> 24) & 0x000000FF) | ((c & 0x00FF0000) >> 8) | ((c & 0x0000FF00) << 8) | ((c & 0x000000FF) <> 8) | ((c & 0x00FF) << 8)
typedef struct s_header {
unsigned short bfType;
unsigned int bfSize;
unsigned short reserved1;
unsigned short reserved2;
unsigned int offset;
} t_bmp_header;
typedef struct s_bmp_info {
unsigned int biSize;
unsigned int biWidth;
unsigned int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned in