0

I need to load a single bitimage to a Pascal program, is there a way to do it or I must draw pixel by pixel?

user3762058
  • 1
  • 1
  • 1

2 Answers2

1

As far as I remember, Turbo pascal had functions

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

BitMap is just a chunk of memory with the bitmap. This way you can get image from screen to memory and vice versa. I think there is no direct function to get image from file to screen. But if you have image in right format on the disc, you can load it to memory and then use PutImage.

swisst
  • 92
  • 8
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...

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

tarzanbappa
  • 4,930
  • 22
  • 75
  • 117