Board index » delphi » putimage/putpixel problem

putimage/putpixel problem

Last Friday I posted this article. I'm posting it again because I'm
not sure about the distribution (default: local). So if you already
read this, skip it.

Hello,
I have a (small) problem. Maybe some-one can give me some help.

When I use the Graph-unit the following code does exactly what I
want it to do:

 (...)
 GetImage(x_b, y_b, x_e, y_e, PVar^ );
 (...)
 BlockWrite( FileVar, PointerVar^, 1);
 (...)
 ClearDevice; FreeMem( PointerVar , Size);
 (...)
 BlockRead( FileVar, PointerVar^, 1);
 (...)
 PutPixel(x,y,red); <--- This is going to be important!
 (...)              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 PutImage(n,m, PointerVar^, NormalPut);
 (...)

 Some months ago someone posted a PutPixel procedure in this news-
 group (If you are the one who posted this ... sorry don't remember your
 name :-)

 Procedure PPixel(X, Y : Word; C : Byte); Assembler;
Asm
   mov dx, 3ceh

   xor ax, ax     { xor ax, ax is one byte less than xor al, al }
   mov ah, c
   out dx, ax

   mov ax, 0f01h
   out dx, ax

   mov cx, x
   and cl, 7
   mov ah, 128d
   shr ah, cl
   mov al, 8
   out dx, ax

   mov ax, 0a000h
   mov es, ax

   mov di, x
   shr di, 3
   mov ax, y     { di = (x div 8) + (y * 80) }
   shl ax, 4
   add di, ax
   shl ax, 2
   add di, ax
   mov al, es:[di]
   mov es:[di], al
End;

When I replace the putpixel(n,m,red) statement in my code by this
PPixel statement, The image doesn't show up anymore. (believe me,
it's hard to find this bug!)

The PPixel is faster than the graph-unit putpixel, so I would like
to use it. But, as I found out, it can cause problems.

If there is someone who knows what's going on here, please explain
it to me.

Thanks in advance,
                   Bruno Bougie

--
B.Bougie, Pleinstraat 23, 4126 RT Hei-en Boeicop, The Netherlands
mailto:bbou...@math.ruu.nl

--
B.Bougie, Pleinstraat 23, 4126 RT Hei-en Boeicop, The Netherlands
mailto:bbou...@math.ruu.nl

 

Re:putimage/putpixel problem


Quote
bbou...@math.ruu.nl (Bruno Bougie) wrote:
>Hello,
>I have a (small) problem. Maybe some-one can give me some help.

>When I use the Graph-unit the following code does exactly what I
>want it to do:

> (...)
> GetImage(x_b, y_b, x_e, y_e, PVar^ );
> (...)
> BlockWrite( FileVar, PointerVar^, 1);
> (...)
> ClearDevice; FreeMem( PointerVar , Size);
> (...)
> BlockRead( FileVar, PointerVar^, 1);
> (...)
> PutPixel(x,y,red); <--- This is going to be important!
> (...)              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> PutImage(n,m, PointerVar^, NormalPut);
> (...)

> Some months ago someone posted a PutPixel procedure in this news-
> group (If you are the one who posted this ... sorry don't remember your
> name :-)

> Procedure PPixel(X, Y : Word; C : Byte); Assembler;
>Asm
>   mov dx, 3ceh

>   xor ax, ax     { xor ax, ax is one byte less than xor al, al }
>   mov ah, c
>   out dx, ax

>   mov ax, 0f01h
>   out dx, ax

>   mov cx, x
>   and cl, 7
>   mov ah, 128d
>   shr ah, cl
>   mov al, 8
>   out dx, ax

>   mov ax, 0a000h
>   mov es, ax

>   mov di, x
>   shr di, 3
>   mov ax, y     { di = (x div 8) + (y * 80) }
>   shl ax, 4
>   add di, ax
>   shl ax, 2
>   add di, ax
>   mov al, es:[di]
>   mov es:[di], al
>End;

>When I replace the putpixel(n,m,red) statement in my code by this
>PPixel statement, The image doesn't show up anymore. (believe me,
>it's hard to find this bug!)

>The PPixel is faster than the graph-unit putpixel, so I would like
>to use it. But, as I found out, it can cause problems.

>If there is someone who knows what's going on here, please explain
>it to me.

>Thanks in advance,
>                   Bruno Bougie

>--
>B.Bougie, Pleinstraat 23, 4126 RT Hei-en Boeicop, The Netherlands
>mailto:bbou...@math.ruu.nl

Check out http://cal42a041.student.utwente.nl/ for fast PutPixel and SVGA routines!

Re:putimage/putpixel problem


Quote
Bruno Bougie wrote:
> When I use the Graph-unit the following code does exactly what I
> want it to do:

<<<SNIP>>>

>  Some months ago someone posted a PutPixel procedure in this news-
>  group

<<<SNIP>>>

Quote

> When I replace the putpixel(n,m,red) statement in my code by this
> PPixel statement, The image doesn't show up anymore.
> Thanks in advance,
>                    Bruno Bougie

After looking at the assembler code of PPixel, I strongly recommend
you search for another fast PutPixel routine. I have never programmed
the 16 color modes, so this is more of a guess :
To set a pixel in that mode, you have to tamper with a mask register,
which is probably one of the OUT instructions in PPixel. I do NOT
see a second out instruction to reset the register, hence leaving
some pixels blocked. This might interfere with you're graphic output.

- Christian Froeschlin

Re:putimage/putpixel problem


Trying to mix your own graphics routines with those of BGI is going to result
in some problems -BGI will expect the video hardware to be in a certain state
and if you use other routines that corrupt that state, you will have problems.
Either write all your own routines (preferable) and abandon the abomination
that is BGI or stick with it.

That probably won't help too much but it's the truth in my experience.

Seeya,
----------------------------====================----------------------------
    - __o     Tim Lewis, 3rd yr computer science, Lancaster uni.
 -  _`\<,_    Mosaic page: http://cent1.lancs.ac.uk/tim/tmain.html
_  (_) /(_)   Email:       csc...@cent1.lancs.ac.uk
              Snail mail:  Grizedale college, Lancaster Uni, N. England. LA14YW
        ---*** Author of ClayWorks, cool 3d editor for DOS ***---
----------------------------====================----------------------------

Other Threads