Windows错误使用图形.h
Windows error using graphics.h
我试图使用C/c++的graphics.h库从一些图像中获得像素值。程序编译没有任何错误或警告,但当我尝试执行它时,打开一个窗口,显示以下消息:"version2.exe遇到问题,需要关闭。"给您带来不便,我们深表歉意。"
我代码:#include <graphics.h>
#include <stdio.h>
/* Macros to set important values for
* size and number of images
*/
#define IMAGES 9
#define WIDTH 200
#define HEIGTH 225
/* Receives the image number and load it using
* readimagefile() function from BGI libary.
*/
void loadImage(int imageNumber);
int main(int argc, char const *argv[])
{
int row, column, image;
int red[HEIGTH][WIDTH][IMAGES], green[HEIGTH][WIDTH][IMAGES], blue[HEIGTH][WIDTH][IMAGES];
int pixelValue;
int finalWindow, currentWindow;
for (image = 0; image < IMAGES; ++image)
{
currentWindow = initwindow(WIDTH, HEIGTH, "current"); // creates window to receive image
setcurrentwindow(currentWindow); // set recent window as the current window
loadImage(image);
for (row = 0; row < HEIGTH; ++row)
{
for (column = 0; column < WIDTH; ++column)
{
pixelValue = getpixel(row, column);
green[column][row][image] = GREEN_VALUE(pixelValue);
red[column][row][image] = RED_VALUE(pixelValue);
blue[column][row][image]= BLUE_VALUE(pixelValue);
}
}
}
getch();
return 0;
}
void loadImage(int imageNumber)
{
char str[5];
sprintf(str, "%i.jpg", imageNumber);
readimagefile(str, 0, 0, WIDTH, HEIGTH);
}
graphics.h
指MS DOS图形库"BGI",由Borland提供。它只支持Borland DOS编译器,不能移植到其他操作系统,除了旧的Windows版本,如Windows 95/98仍然支持DOS。
graphics.h是Borlando编译器(例如turbo c)在20世纪90年代使用的库,现在该库非常过时,并且不被主要编译器支持。您可以使用编译器定义的图形库函数来代替graphics.h。图形函数因不同的编译器而不同,因为它们不是标准c语言的一部分,它们在不同的编译器中实现不同
相关文章:
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 将图形表示为unordered_map<字符串、向量>时拓扑排序错误<string>
- 增加图形转换错误
- 我该如何解决错误,说明创建图形对象没有放置在图形场景中
- C++:basic_string::_M_construct 空,对于图形 BFS 算法无效错误
- C++图形初始化错误(语法或丢失文件缺陷?
- 矢量迭代器在尝试对图形进行深度优先搜索时导致分割错误 11
- VS 2015图形调试器给我源错误
- 在Mac OS X(10.7)上安装图形工具-已经安装了Boost,但不断出现此错误
- 包含相邻顶点列表的自定义顶点类型[图形]:不完整类型错误
- Qt - 拖放 - 自定义图形场景 - 事件错误
- 使用图形函数(vtk 6.1,Qt5.3,Ubuntu)时的分段错误
- collect2:错误:ld 返回 1 个退出状态图形
- 将错误与图形魔术链接
- 图形 dfs 运行时错误
- 图形库中的CodeBlocks错误
- Windows错误使用图形.h
- 通过boost发送一个简单的boost图形对象:MPI得到错误
- Stroupstrup图形库错误
- 增强图形库,在应用 dijkstra 算法时导致错误