TGC Codebase Backup



Negative Image by Tapewormz

19th Jan 2005 20:42
Summary

Generate a negative of an image.



Description

An example of how one might convert a positive image into a negative image. May possibly be of some use as an effect.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    REM Project: Negative Image
REM Created: 01/19/2005 8:00:00 PM
REM
REM ***** Main Source File *****
REM

SET DISPLAY MODE 1024,768,32

positive AS BYTE
negative AS BYTE

LOAD IMAGE "(your image file here)",1,1

MAKE MEMBLOCK FROM IMAGE 1,1

`Convert positive to negative image using bitwise xor
FOR l=12 TO GET MEMBLOCK SIZE(1)-8
   positive=MEMBLOCK BYTE(1,l)
   negative=%11111111111111111111111111111111 ~~ positive
   WRITE MEMBLOCK BYTE 1,l,negative
NEXT l

MAKE IMAGE FROM MEMBLOCK 2,1

`Display before image
PASTE IMAGE 1,0,0
TEXT 0,MEMBLOCK DWORD(1,4)+20,"Before"

`Display after image
PASTE IMAGE 2,MEMBLOCK DWORD(1,0),0
TEXT MEMBLOCK DWORD(1,0),MEMBLOCK DWORD(1,4)+20,"After"

WAIT KEY
END