2014-10-29 70 views

回答

0

通過使用圖形單位,你可以加載渦輪帕卡爾BGI圖形。

請參閱本作的詳細信息...

http://pascal-programming.info/lesson8.php

這裏是從上面的鏈接示例代碼...

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. 

請參閱本作的詳細信息...

http://pascal-programming.info/lesson8.php

+0

BGI文件不是圖像,而是Borland圖形接口的驅動程序。 – Fabel 2016-07-29 00:42:46

0

只要我記住ber,Turbo pascal有功能

GetImage(X1, Y1, X2, Y2: integer; var BitMap) 
PutImage(X, Y: integer; var BitMap; BitBlt: word); 

BitMap只是一塊帶有位圖的內存塊。這樣你就可以從屏幕獲取圖像到內存,反之亦然。我認爲從文件到屏幕沒有直接的功能。但是如果光盤上的圖像格式正確,則可以將其加載到內存中,然後使用PutImage。

相關問題