我需要将单个位图加载到 Pascal 程序中,有没有办法做到这一点,或者我必须逐个像素地绘制?
问问题
3030 次
2 回答
1
据我记得,Turbo pascal 有函数
GetImage(X1, Y1, X2, Y2: integer; var BitMap)
PutImage(X, Y: integer; var BitMap; BitBlt: word);
BitMap 只是带有位图的一块内存。这样,您可以将图像从屏幕获取到内存,反之亦然。我认为没有直接的功能可以将图像从文件获取到屏幕。但是,如果您的光盘上有正确格式的图像,您可以将其加载到内存中,然后使用 PutImage。
于 2015-03-27T21:58:42.637 回答
0
By using graph unit you can load BGI graphics in turbo pascal.
Refer this for more info...
http://pascal-programming.info/lesson8.php
Here is a sample code from the above link...
Program Lesson8_Program1;
Uses Crt,Graph;
Var GraphicsDriver, GraphicsMode,
ErrCode : Integer;
{two var's are needed for initialisation}
Begin
Writeln('Initialising Graphics, please wait...');
GraphicsDriver := Detect;
InitGraph(GraphicsDriver, GraphicsMode,'');
{IMPORTANT, read the following or
otherwise graphics will not work!! ;)}
(*between the inverted commas,
type in the path of the graphics BGI file
(usually 'C:\TP\BGI'),
OR
change the dir in the file menu (PRESS Alt+F)
and roll down your mouse pointer to the 'change dir'
menu; then either type the path to the BGI file,
or go to C: -> TP -> BGI*)
ErrCode := GraphResult;
If GraphResult <> grOK then { <> means 'not equal to' }
Begin
ClrScr;
Writeln('Graphics error occured: ',
GraphErrorMsg(ErrCode));
Writeln('If a file not found error is displayed above');
Writeln('then, change the dir from the current');
Writeln('location to C:\ -> TP -> BGI, '+
+'from the file menu!');
Readln;
Halt(1);
End Else
Begin
Randomize;
SetColor(Random(15) + 1); {Set text colour}
{Output text at 20 pixels from the top of the screen,
and 20 other from the left side of the screen.}
OutTextXY(20,20,'Welcome to the new generation
of Pascal Programming:');
OutTextXY(20,30,'Pascal Graphics!!');
OutTextXY(25,70,'You will learn more
graphics procedures and');
OutTextXY(25,80,'functions, later in this lesson :-)');
Readln;
End;
CloseGraph;
End.
Refer this for more info...
于 2014-10-29T04:35:26.293 回答