本文目錄一覽:
- 1、graphics什麼意思?
- 2、C語言,codeblocks+gcc編譯環境中關於「graphics.h」頭文件的問題
- 3、頭文件到底是什麼?
- 4、c語言中的graphics.h問題
- 5、“graphics.h”在C里有什麼作用?
- 6、#include是什麼意思
graphics什麼意思?
圖樣。
讀音:英 [ˈɡræfɪks] 美 [ˈɡræfɪks]
例子,
Computer graphics will give your presentation the professional touch.
計算機繪圖將會使你的演示具有專業特色。
graphics.h介紹
graphics.h是TC的針對DOS下的一個C語言圖形庫,如果要用的話應該用TC的編譯器來編譯,VC++環境有其它的針對Windows的圖形庫。分為:像素函數、直線和線函數、多邊形函數、填充函數等。
如果有需要在VC及VS環境中使用graphics.h的功能,可以下載EasyX圖形庫(注意:這是一個C++的圖形庫,如果一定要在C語言環境下使用graphics.h,可以使用Windows GDI。)
C語言,codeblocks+gcc編譯環境中關於「graphics.h」頭文件的問題
graphics.h對應的是TC提供的圖形庫,是TC獨有的,你用其它編譯器來編譯它,當然會報錯。而且,據我所知,這個庫,用一般方法貌似是無法移植到gcc的,除非在新的環境下使用舊的函數接口重寫相應的庫。
老實說,你這個問題,問得有點傻。你用MFC寫的WINDOWS源代碼,能放到LINUX下的GCC編譯通過嗎?顯然是不可能的。
此外,conio.h這個頭文件也有類似的問題。這個頭文件主要是對DOS下的輸入輸出的支持,你弄到非DOS環境下,那就不一定有用了(就算把庫導入進來,編譯通過,也是這樣.除非該環境對DOS兼容)。
我覺得更有意思的是,你居然把windows.h包含進來,真不知道你在想什麼。DOS下的繪圖和WINDOWS下的繪圖,完全兩回事。建議你多讀讀關於操作系統方面的書,弄清楚基於某個操作系統編程的基本問題。
頭文件到底是什麼?
graphics.h是TC裏面的圖形庫,如果要用的話應該用TC來編譯,VC++有他自己的另外圖形庫。
它包括像素函數、直線和線型函數、多邊形函數、圓、弧和曲線函數的定義。
(TC是Turbo C,是很老的C編譯軟件了。)
所以你用VC編譯不能通過
c語言中的graphics.h問題
你用的是tc嗎 tc下才有這個頭文件
Turbo C對於用initgraph()函數直接進行的圖形初始化程序,
在編譯和鏈接
時並沒有將相應的驅動程序(*.BGI)裝入到執行程序, 當程序進行到intitgraph()
語句時,
再從該函數中第三個形式參數char *path中所規定的路徑中去找相應的
驅動程序。若沒有驅動程序, 則在C:\TC中去找,
如C:\TC中仍沒有或TC不存在,
將會出現錯誤:
BGI Error: Graphics
not initialized (use ‘initgraph’)
因此, 為了使用方便,
應該建立一個不需要驅動程序就能獨立運行的可執行
圖形程序,Turbo C中規定用下述步驟(這裡以EGA、VGA顯示器為例):
1. 在C:\TC子目錄下輸入命令:BGIOBJ EGAVGA
此命令將驅動程序EGAVGA.BGI轉換成EGAVGA.OBJ的目標文件。
2.
在C:\TC子目錄下輸入命令:TLIB LIB\GRAPHICS.LIB+EGAVGA
此命令的意思是將EGAVGA.OBJ的目標模塊裝到GRAPHICS.LIB庫文件中。
3.
在程序中initgraph()函數調用之前加上一句:
registerbgidriver(EGAVGA_driver):
該函數告訴連接程序在連接時把EGAVGA的驅動程序裝入到用戶的執行程序中。
經過上面處理,編譯鏈接後的執行程序可在任何目錄或其它兼容機上運行。
“graphics.h”在C里有什麼作用?
“graphics.h”在做c語言的圖形圖象上很有用,有函數可以執行圖形圖象的初始化和畫直線,圓,還有在圖象中輸出漢字.如果要做圖形程序的話就會用到.
#include是什麼意思
首先,#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, // second radial ending point int nYEndArc // second 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 second radial’s endpoint int nYRadial2 // y-coord of second 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);
畫一個橢圓並填充EllipseBOOL Ellipse( 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毒害了……
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/291835.html