# 【C工具】------点阵模拟测试2

2022-06-23 16:49:56来碗豆腐脑

## 前言

【C工具】------点阵模拟测试

## 使用easyx图形库

1. 画矩形，也就是点阵图的画点, 一个点阵图片点为3*3,实际填充2*2,这样点和点之间留了条空隙
``````void draw_point(int x,int y)
{

int x1, x2, y1, y2;
x1 = (x+1) * 3 - 1;
x2 = (x+1) * 3;
y1 = (y + 1) * 3 - 1;
y2 = (y + 1) * 3;
fillrectangle(x1, y1, x2, y2);
}
``````
1. 清除画布，没什么可说的，清屏
``````void cleardevice();
``````

## 读取bin文件

``````#include <iostream>
#include <fstream>
//以二进制打开文件
std::ifstream infile("./bin.bin",std::ios::binary);
//读出数据，256*160的固定分辨率
//文件关闭
infile.close();
``````

``````	void run()
{

int i, j, k;
switch (Data_mode)
{

case MODE_1:												//行列式刷新
for (i = 0; i < 20; i++)
{

for (j = 0; j < 256; j++)
{

for (k = 0; k < 8; k++)
{

if (byte_mode == 0)
{

if (reverse == 0)
{

if (!(show_buf[i * 256 + j] & (0x01 << k)))
{

draw_point(j, i * 8 + k);
}
}
else if(reverse == 1)
{

if (show_buf[i * 256 + j] & (0x01 << k))
{

draw_point(j, i * 8 + k);
}
}
}
else if (byte_mode == 1)
{

if (reverse == 0)
{

if (!(show_buf[i * 256 + j] & (0x80 >> k)))
{

draw_point(j, i * 8 + k);
}
}
else if(reverse == 1)
{

if (show_buf[i * 256 + j] & (0x80 >> k))
{

draw_point(j, i * 8 + k);
}
}
}
}
}
}
break;
}
}
``````

end。。。

https://blog.csdn.net/a1058191679/article/details/125380321