graphics.h是什么頭文件
文件如下:
graphics.h頭文件是C語言和visual studio的圖形庫文件,包含像素函數、線型函數、畫線函數、相對畫線函數等多種函數,可進行圖形的快速編程,如果您的電腦缺少graphics.h頭文件就需要下載安裝一下,就可實現圖形繪制功能了。
其他文件類型說明
alloc.h:說明內存管理函數(分配、釋放等)。
asrt.h:定義asrt調試宏。
bios.h:說明調用IBM—PC ROM BIOS子程序的各個函數。
conio.h:說明調用DOS控制臺I/O子程序的各個函數。
ctype.h:包含有關字符分類及轉換的名類信息(如isalpha和toascii等)。
dir.h:包含有關目錄和路徑的結構、宏定義和函數。
dos.h:定義和說明MSDOS和8086調用的一些常量和函數。
C++怎么用GRAPHICS.H?
由于graphics.h是TC系列的圖形庫處理函數,不是標準庫內容。而DEV-C++的編譯器是GCC,所以DEV-C++中不包含該類庫。要想使用,首先先下載兩個文件:
graphics.h (放入DEV-C++的安裝路徑/Dev-Cpp/include/)
libbgi.a (放入DEV-C++的安裝路徑/Dev-Cpp/lib/)
然后再在DEV-C++的工具欄中 工程(Project)->工程屬性(Project Options)-> 參數(Parameters)的 連接器(Linker)中
增加
-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32
這樣就可以使用#include<graphics.h>了。
graphics.h在Devc++用什么代替
graphics.h在Devc++用graphics.h頭函數代替。
DEVC++不支持graphics.h頭函數,而且:不支持不等于不提供即使你復制進去,也無法連接相關庫。
如果的確想用DEV來寫可視化、圖形化界面,可以使用windows.h,通過調用相關API,可以支持所有圖形操作TC下才有這個文件。
graphics.h不是語言的一部分,是Borland公司的TC/BC系列產品的一部分,DOS下的一個圖形驅動。如果你更改了tc的編譯環境,那就要重新設置。要是用了非TC的編譯器,那是絕對不行的。
Devc++:
(1)它集成了 AStyle 源代碼格式整理器,只要點擊菜單“AStyle”下的“ 格式化當前文件”,就可以把當前窗口中的源代碼按一定的風格迅速整理好排版格式。在當前的 Banzhusoft Dev-C++ v5.15中,默認在保存文件時就自動對當前源代碼文件進行格式化整理。
(2)它提供了一些常用的源代碼片段,只要點擊“插入”按鈕就可以選擇性地插入常用源代碼片段。
(3)支持單文件開發和多文件項目開發。可以針對單文件(無需建立項目)進行編譯或調試。
graphics.h的像素函數
功能: 函數putpixel() 在圖形模式下屏幕上畫一個像素點。
用法:函數調用方式為void putpixel(int x,int y,int color);
說明: 參數x,y為像素點的坐標,color是該像素點的顏色,它可以是顏色符號名,也可以是整型色彩值。
此函數相應的頭文件是graphics.h
返回值: 無
例: 在屏幕上(6,8)處畫一個紅色像素點:
putpixel(6,8,RED); 功能: 函數getpixel()返回像素點顏色值。
用法: 該函數調用方式為int getpixel(int x,int y);
說明: 參數x,y為像素點坐標。
函數的返回值可以不反映實際彩色值,這取決于調色板的設置情況(參見tpalette()函數)。
這個函數相應的頭文件為graphics.h
返回值: 返回一個像素點色彩值。
例: 把屏幕上(8,6)點的像素顏色值賦給變量color。
color=getpixel(8,6);
沒有graphics.h 怎么解決
1、首先看到圖中的紅色選框中的兩個文件夾,將其下載下來。
2、接下來,我們先打開下載的include文件夾,將里面的兩個文件,復制下來。
3、接著,找到我們的vs安裝的地方,打開VC-include。
4、右鍵,粘貼。注意,這里配圖不是你會出現的,樓主是因為之前已經弄過一次,為了演示才粘貼第二次的。本身并沒有這兩個文件。
5、接著,我們打開一開始下載的另一個lib文件。
6、將里面的文件,全部選中,復制。
7、同樣找到VS安裝的地方,VC-lib,粘貼下來。
8、接下來,我們就可以打開我們的VS了。#include <graphics.h>就可以用了。
#include<graphics.h>是什么意思
首先,#include "graphics.h"是TC專屬的一個畫圖函數,因為它不是標準庫,VC是沒有的,VC有自己的圖形函數。我到沒有試過下載#include "graphics.h",因為需要在VC運行#include "graphics.h"是需要插件的,而且#include "graphics.h"是在DOS黑框的畫圖,不美觀,而且已經過時了,真正做項目什么的,一般用VC
VC畫圖函數
1、畫筆有兩種形式創建畫筆一是直接通過GetStockObject()函數來調用二是通過創建畫筆來調用HPEN CreatePen(intfnPenStyle,// pen styleintnWidth,// pen widthCOLORREFcrColor// pen color);
創建畫筆后必須調用SelectObject函數來將起選入設備環境;
刪除畫筆可通過DeleteObject 函數來實現;
2、畫刷創建畫刷
一是通過GetStockObject函數來調用
二是通過調用CreateSolidBrush 和CreateHatchBrush來創建畫刷HBRUSH CreateSolidBrush( COLORREF crColor // brush color value);
HBRUSH CreateHatchBrush( int fnStyle, // hatch style COLORREF clrref // color value);3、顏色通過RGB函數來實現;4、常用的繪圖函數設置畫筆當前的位置函數MoveToExBOOL MoveToEx( HDC hdc, // handle to device context int X, // x-coordinate of new current position int Y, // y-coordinate of new current position LPPOINT lpPoint // pointer to old current position);
從當前位置向指定坐 點畫直線的函數LineToBOOL LineTo( HDC hdc, // device context handle int nXEnd, // x-coordinate of line's ending point int nYEnd // y-coordinate of line's ending point);
從當前位置開始,依次用線段連接lpPoints中指定各點的函數PolylineBOOL Polyline( HDC hdc, // handle to device context CONST POINT *lppt, // pointer to array containing endpoints int cPoints // number of points in the array);
橢圓弧線ArcBOOL Arc( HDC hdc, // handle to device context int nLeftRect, // x-coord of bounding rectangle's upper-left corner int nTopRect, // y-coord of bounding rectangle's upper-left corner int nRightRect, // x-coord of bounding rectangle's lower-right corner int nBottomRect, // y-coord of bounding rectangle's lower-right corner int nXStartArc, // first radial ending point int nYStartArc, // first radial ending point int nXEndArc, // cond radial ending point int nYEndArc // cond radial ending point);畫一個餅圖并用當前的畫刷進行填充PieBOOL Pie( HDC hdc, // handle to device context int nLeftRect, // x-coord of bounding rectangle's upper-left corner int nTopRect, // y-coord of bounding rectangle's upper-left corner int nRightRect, // x-coord of bounding rectangle's lower-right corner int nBottomRect, // y-coord of bounding rectangle's lower-right corner int nXRadial1, // x-coord of first radial's endpoint int nYRadial1, // y-coord of first radial's endpoint int nXRadial2, // x-coord of cond radial's endpoint int nYRadial2 // y-coord of cond radial's endpoint);
畫一個矩形,并填充RectangleBOOL Rectangle( HDC hdc, // handle to device context int nLeftRect, // x-coord of bounding rectangle's upper-left corner int nTopRect, // y-coord of bounding rectangle's upper-left corner int nRightRect, // x-coord of bounding rectangle's lower-right corner int nBottomRect // y-coord of bounding rectangle's lower-right corner);
畫一個橢圓并填充EllipBOOL Ellip( HDC hdc, // handle to device context int nLeftRect, // x-coord of bounding rectangle's upper-left corner int nTopRect, // y-coord of bounding rectangle's upper-left corner
樓主,我也說老實話,我也是學習中的,希望你可以體諒,我個人認為知識是自己積累的,圖像編程也是我希望學習的方面,希望你努力,還有,控件只是工具,不能解決一切問題……你是不是學過VB,如果是你就被VB毒害了……