Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Graphics in Pascal

GatisGatis Member Posts: 6
I'm a newbie trying to turn from QBasic to TurboPascal and I'd like to do some graphics programming, but i dont know how...
Below is one short part of my QBasic program, I'd like to know - can something like this be done in Pascal also? HOW it can be done?
If it's not too much please give me some short exmple...
You can contact me using e-mail also...
My e-mail is [email protected]
Thank You very much...

'Here's an QBasic example
SCREEN 12 'puts screen to mode (640x480) x16 colors
DIM klucis(225) 'bitmap size (x*y)
FOR y = 1 TO 15 'how many rows of pixels does picture contain
FOR x = 1 TO 15 'how many columns of pixels it contain
READ klucis 'reads pixels line by line from DATA lines
PSET (x, y), klucis 'puts pixels on sscreen
NEXT
NEXT
GET (1, 1)-(15, 15), klucis 'puts image to memory and assigns a name

PUT (100,100),klucis, PSET 'Joy can change x,y and it puts image there

'Below is bitmap of image for reading&putting on screen
DATA 00,15,15,15,15,15,15,14,14,14,14,14,14,14,00
DATA 15,15,15,15,15,15,15,14,14,14,14,14,00,00,14
DATA 15,15,15,15,15,15,15,14,14,14,14,14,14,00,14
DATA 15,15,15,15,15,15,15,14,14,14,14,14,00,00,14
DATA 15,15,15,15,15,15,15,14,14,14,14,00,14,00,14
DATA 15,15,15,15,15,15,15,14,14,14,14,14,00,00,14
DATA 15,15,15,15,15,15,15,14,14,14,14,00,14,00,14
DATA 14,14,14,14,14,14,14,10,10,10,10,10,00,00,10
DATA 14,14,14,14,14,14,14,10,10,10,10,00,10,00,10
DATA 14,14,00,14,00,14,00,10,00,10,00,10,00,00,10
DATA 14,00,14,00,14,00,14,00,10,00,10,00,00,00,10
DATA 14,00,00,00,00,00,00,00,00,00,00,00,00,00,10
DATA 14,00,00,00,00,00,00,00,00,00,00,00,00,00,10
DATA 14,14,00,14,00,14,00,10,00,10,00,10,00,10,10
DATA 00,14,14,14,14,14,14,10,10,10,10,10,10,10,00

Comments

  • Phat NatPhat Nat Member Posts: 757
    : I'm a newbie trying to turn from QBasic to TurboPascal and I'd like to do some graphics programming, but i dont know how...
    : Below is one short part of my QBasic program, I'd like to know - can something like this be done in Pascal also? HOW it can be done?
    : If it's not too much please give me some short exmple...
    : You can contact me using e-mail also...
    : My e-mail is [email protected]
    : Thank You very much...
    :
    : 'Here's an QBasic example
    : SCREEN 12 'puts screen to mode (640x480) x16 colors
    : DIM klucis(225) 'bitmap size (x*y)
    : FOR y = 1 TO 15 'how many rows of pixels does picture contain
    : FOR x = 1 TO 15 'how many columns of pixels it contain
    : READ klucis 'reads pixels line by line from DATA lines
    : PSET (x, y), klucis 'puts pixels on sscreen
    : NEXT
    : NEXT
    : GET (1, 1)-(15, 15), klucis 'puts image to memory and assigns a name
    :
    : PUT (100,100),klucis, PSET 'Joy can change x,y and it puts image there
    :
    : 'Below is bitmap of image for reading&putting on screen
    : DATA 00,15,15,15,15,15,15,14,14,14,14,14,14,14,00
    : DATA 15,15,15,15,15,15,15,14,14,14,14,14,00,00,14
    : DATA 15,15,15,15,15,15,15,14,14,14,14,14,14,00,14
    : DATA 15,15,15,15,15,15,15,14,14,14,14,14,00,00,14
    : DATA 15,15,15,15,15,15,15,14,14,14,14,00,14,00,14
    : DATA 15,15,15,15,15,15,15,14,14,14,14,14,00,00,14
    : DATA 15,15,15,15,15,15,15,14,14,14,14,00,14,00,14
    : DATA 14,14,14,14,14,14,14,10,10,10,10,10,00,00,10
    : DATA 14,14,14,14,14,14,14,10,10,10,10,00,10,00,10
    : DATA 14,14,00,14,00,14,00,10,00,10,00,10,00,00,10
    : DATA 14,00,14,00,14,00,14,00,10,00,10,00,00,00,10
    : DATA 14,00,00,00,00,00,00,00,00,00,00,00,00,00,10
    : DATA 14,00,00,00,00,00,00,00,00,00,00,00,00,00,10
    : DATA 14,14,00,14,00,14,00,10,00,10,00,10,00,10,10
    : DATA 00,14,14,14,14,14,14,10,10,10,10,10,10,10,00
    :

    Yep. Look in the documentation under InitGraph() and PutPixel(). I haven't used these routines in a long time, but they will do what you want.

    Or since you are already decalring the Video mode that you wish to use, you can use the following assembler inline code:
    [code]
    PROCEDURE Screen(Mode : Byte); Assembler
    ASM
    Xor Ax, Ax
    Mov Al, Mode
    Int $10
    End;
    [/code]

    and to place a pixel on the screen:
    [code]
    PROCEDURE PutPixel(X,Y : Word; Color : Byte);
    Begin
    Mem[$A000:X+Y*SCrWidth] := Color;
    End;
    [/code]

    where ScrWidth is a WORD representation of the number of pixels across the screen. (In the case of mode $12, it would be 80 (640/8 bits))

    Anyways, not sure how wel this method works for non-256 color screens. You may want to use the InitGraph() method.

    Phat Nat


Sign In or Register to comment.