Mask Creator (improved)

Discussions related to graphics (2D and 3D), animation and games programming
Post Reply
michael
Posts: 15
Joined: Mon 02 Apr 2018, 17:13

Mask Creator (improved)

Post by michael » Mon 31 Dec 2018, 00:04

I made a major improvement to the mask tool I created long ago. I realized that it was not producing a proper image for sprites.. (some character info was not being shown due to the pixel size.)
This fix should be flaw free.
INFO:
"manstand" should be replaced with the file you want to mask. The "bmp" extension is automatically added
Let me know if you have problems applying this program to your image.
Thanks.

Code: Select all

      MODE 8 :REM a graphics screen
      GCOL 14 :REM pick a drawing core color
      VDU 5 :REM make text use graphics coordinates
      OFF:REM turn off the flashing text cursor
      REM change pixel size for mask accuracy
      PROCdotsize(1)
      REM First load the original image (BMP image) (this was stretched for my game)
      PROCloadbmp("manstand",0,0,80,80)
      REM now make a mask  (You must modify the edges to make the image capture look good)
      PROCmask(0,0,70,85)
      REM now that the mask is created, save the new image ( the mask created will add another 80 to the top, but the horizontal will remain close to the same and you may need to adjust for imperfections)
      PROCsavebmp("maskedimage",0,0,70,160)
      REM after this you may run this program again and create another.. (make sure you change the image name and the name it will be saved to.)
      MOVE 10,500
      PRINT "Mask created and saved !!!!"
      MOVE 0,0 :REM move the cursor off view
      END
      REM program ends
      DEFPROCdotsize(n)
      VDU 23,23,n|
      ENDPROC
      REM * REMEMBER - x%,y% is lower left of image h% is pixels right and v% is pixels up
      DEFPROCsavebmp(name$,x%,y%,h%,v%)
      OSCLI "SCREENSAVE """+name$+""" "+STR$(x%)+","+STR$(y%)+","+STR$(h%)+","+STR$(v%)
      ENDPROC
      REM The image can be stretched or shrunk by increasing h% and v% over the size of the image
      REM same applies if you make it smaller than the original (cool eh?)
      DEFPROCloadbmp(name$,x%,y%,h%,v%)
      OSCLI "DISPLAY """+name$+""" "+STR$(x%)+","+STR$(y%)+","+STR$(h%)+","+STR$(v%)
      ENDPROC
      REM NOTE this version has been modified on November 4 2018 (it is NOT exactly the same as RETROLIB 10 version)
      REM h and v must always be a higher value as they are the top right corner of the image.( I make make this smart like sbox)
      DEFPROCmask(x%,y%,h%,v%)
      LOCAL dx%,dy%,c%,counx%,couny%
      counx%=0:couny%=0
      dx%= h%-x%
      dy%= v%-y%
      IF dx%>dy% THEN
        REPEAT
          c%=TINT(x%+counx%,y%+couny%)
          IF c%=0 THEN PROCpixel(x%+counx%,y%+couny%+dy%+1,248,248,248) ELSE PROCpixel(x%+counx%,y%+couny%+dy%+1,0,0,0)
          couny%+=1:IF couny%=y%+dy% THEN couny%=0:counx%=counx%+1
        UNTIL counx%=dx%
      ENDIF
      IF dy%>dx% THEN
        REPEAT
          c%=TINT(x%+counx%,y%+couny%)
          IF c%=0 THEN PROCpixel(x%+counx%,y%+couny%+dy%+1,255,255,255) ELSE PROCpixel(x%+counx%,y%+couny%+dy%+1,0,0,0)
          counx%+=1:IF counx%=x%+dx% THEN counx%=0:couny%=couny%+1
        UNTIL couny%=dy%
      ENDIF
      ENDPROC
      DEFPROCpixel(x%,y%,c1%,c2%,c3%)
      COLOUR 0,c1%,c2%,c3% :GCOL 0
      MOVE x%,y%:DRAW x%,y%
      ENDPROC
      REM restore default color palettes
      DEFPROCresetrgb
      COLOUR 0,0,0,0 :COLOUR 1,200,0,0 :COLOUR 2,000,200,000
      COLOUR 3,200,200,000:COLOUR 4,000,000,200:COLOUR 5,200,000,200
      COLOUR 6,000,200,200:COLOUR 7,200,200,200:COLOUR 8,056,056,056
      COLOUR 9,248,056,056:COLOUR 10,056,248,056:COLOUR 11,248,248,056
      COLOUR 12,056,056,248:COLOUR 13,248,056,248:COLOUR 14,056,248,248
      COLOUR 15,248,248,248
      ENDPROC

Post Reply