加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
绘制字符图.cpp 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
破竹 提交于 2019-11-29 10:58 . bitmap
/************************************
图像处理系统,ReadBitMap
*************************************/
#include"bm.h"
#include<math.h>
void main()
{
int be = 2;
long poitn = 0;
BITMAP_PZ bm = CreMap_pz("66.bmp");
BITMAP_PZ bm1 = CreMap_pz("22.bmp");
FILE *poit;
poit = fopen("poit.txt", "w");
int m = bm.BitInfoHead.biWidth / 2;
int n = bm.BitInfoHead.biHeight / 2;
int x, y, z;
initgraph(bm.BitInfoHead.biWidth/5*4, bm.BitInfoHead.biHeight);
int oo = 0;
for (int j = 0; j < bm.BitInfoHead.biHeight; j += 15)
{
for (int i = 0; i < bm.BitInfoHead.biWidth; i += 15)
{
RGBQUAd rgbb = GetPix(&bm, i, j);
//if (sqrt(pow((double)(m - i), 2) + pow((double)(n - j), 2)) >200 )
{
//putpixel(i, j, RGB(rgbb.rgbRed, rgbb.rgbGreen, rgbb.rgbBlue));
settextstyle(8, 8, _T("幼圆"));
if (rgbb.rgbRed*0.299 + rgbb.rgbGreen*0.578 + rgbb.rgbBlue*0.114 >= 240)
outtextxy(i-100, j, L".");
else if (rgbb.rgbRed*0.299 + rgbb.rgbGreen*0.578 + rgbb.rgbBlue*0.114 >= 100)
outtextxy(i - 100, j, L".");
else if (rgbb.rgbRed*0.299 + rgbb.rgbGreen*0.578 + rgbb.rgbBlue*0.114 >= 80)
outtextxy(i - 100, j, L"人");
else if (rgbb.rgbRed*0.299 + rgbb.rgbGreen*0.578 + rgbb.rgbBlue*0.114 >= 60)
outtextxy(i - 100, j, L"节");
else if (rgbb.rgbRed*0.299 + rgbb.rgbGreen*0.578 + rgbb.rgbBlue*0.114 >= 40)
outtextxy(i - 100, j, L"乐");
else if (rgbb.rgbRed*0.299 + rgbb.rgbGreen*0.578 + rgbb.rgbBlue*0.114 >= 20)
outtextxy(i - 100, j, L"快");
else
outtextxy(i - 100, j, L"情");
poitn++;
oo++;
}
}
fprintf(poit, "\n");
}
RGBQUAd rgbp;
fclose(poit);
CloseBM_pz(bm); //关闭位图
getchar();
getchar();
closegraph();
printf("\n");
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化