Author Topic: Black and White  (Read 3863 times)

0 Members and 1 Guest are viewing this topic.

Offline Craz1000

  • Forum Regular
  • Posts: 111
  • I'm OK
    • View Profile
    • Craz1000.net
Black and White
« on: January 02, 2021, 05:39:15 pm »


So currently at the point where I am adding the death animation or cut scene to the Zelda clone.
I have multiple layers drawn to Sprites&, and Scene&, Which eventually get stacked layer by layer into Buffer& then gets copied to Display& which is what the player sees.

In the original Zelda the screen goes black and white. So I would have to get Buffer& to convert to greyscale before sending it over to Display&
What would be the best way to do this?


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Black and White
« Reply #1 on: January 02, 2021, 05:55:02 pm »
I would colorize the version. :)

Offline Craz1000

  • Forum Regular
  • Posts: 111
  • I'm OK
    • View Profile
    • Craz1000.net
Re: Black and White
« Reply #2 on: January 02, 2021, 06:11:26 pm »
That would be easier. But not proper. :)
Trying to get this as close of a clone as I can.
« Last Edit: January 02, 2021, 06:12:29 pm by Craz1000 »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Black and White
« Reply #3 on: January 02, 2021, 06:14:13 pm »
That would be easier. But not proper. :)
Trying to get this as close of a clone as I can.

No color at all? Then I would convert images as I loaded them, it would save time while game is running. Do you need code for that?

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Black and White
« Reply #4 on: January 02, 2021, 06:33:04 pm »
best way is to have a palatalized image(like screen 13 uses), and shift the palette to black and white for the effect.
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Black and White
« Reply #5 on: January 02, 2021, 06:51:09 pm »
Too late to answer, done!

Code: QB64: [Select]
  1. _TITLE "Convert to B&W" 'b+ 2021-01-02
  2.  
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4. _DELAY .25
  5.  
  6. testi& = _LOADIMAGE("ornament.png", 32)
  7.  
  8. _PUTIMAGE (0, 0), testi&, 0
  9. PRINT "Before"
  10. convert2BW testi&, newi&
  11. _PUTIMAGE (0, 0), newi&, 0
  12. PRINT "After"
  13.  
  14. SUB convert2BW (imageh&, newh&)
  15.     storeDest = _DEST
  16.     iw& = _WIDTH(imageh&): ih& = _HEIGHT(imageh&)
  17.     newh& = _NEWIMAGE(iw&, ih&, 32)
  18.     _SOURCE imageh&
  19.     _DEST newh&
  20.     FOR y = 0 TO ih& - 1
  21.         FOR x = 0 TO iw& - 1
  22.             cAnalysis POINT(x, y), rr, gg, bb, aa
  23.             mix = (rr + gg + bb - 10) / 3
  24.             LINE (x, y)-STEP(0, 0), _RGB32(mix, mix, mix, aa), BF
  25.         NEXT
  26.     NEXT
  27.     _FREEIMAGE imageh&
  28.     _DEST storeDest
  29.  
  30. SUB cAnalysis (c AS _UNSIGNED LONG, outRed, outGrn, outBlu, outAlp)
  31.     outRed = _RED32(c): outGrn = _GREEN32(c): outBlu = _BLUE32(c): outAlp = _ALPHA32(c)
  32.  
  33.  
  34.  

  [ You are not allowed to view this attachment ]  

   [ You are not allowed to view this attachment ]  



Demo here

Oops! ziped folder before saved bas file, fixed zip now.
« Last Edit: January 02, 2021, 09:15:53 pm by bplus »

Offline Craz1000

  • Forum Regular
  • Posts: 111
  • I'm OK
    • View Profile
    • Craz1000.net
Re: Black and White
« Reply #6 on: January 02, 2021, 06:56:51 pm »
Too late to answer, done!

Code: QB64: [Select]
  1. _TITLE "Convert to B&W" 'b+ 2021-01-02
  2.  
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4. _DELAY .25
  5.  
  6. testi& = _LOADIMAGE("ornament.png", 32)
  7.  
  8. _PUTIMAGE (0, 0), testi&, 0
  9. PRINT "Before"
  10. convert2BW testi&, newi&
  11. _PUTIMAGE (0, 0), newi&, 0
  12. PRINT "After"
  13.  
  14. SUB convert2BW (imageh&, newh&)
  15.     storeDest = _DEST
  16.     iw& = _WIDTH(imageh&): ih& = _HEIGHT(imageh&)
  17.     newh& = _NEWIMAGE(iw&, ih&, 32)
  18.     _SOURCE imageh&
  19.     _DEST newh&
  20.     FOR y = 0 TO ih& - 1
  21.         FOR x = 0 TO iw& - 1
  22.             cAnalysis POINT(x, y), rr, gg, bb, aa
  23.             mix = (rr + gg + bb - 10) / 3
  24.             LINE (x, y)-STEP(0, 0), _RGB32(mix, mix, mix, aa), BF
  25.         NEXT
  26.     NEXT
  27.     _FREEIMAGE imageh&
  28.     _DEST storeDest
  29.  
  30. SUB cAnalysis (c AS _UNSIGNED LONG, outRed, outGrn, outBlu, outAlp)
  31.     outRed = _RED32(c): outGrn = _GREEN32(c): outBlu = _BLUE32(c): outAlp = _ALPHA32(c)
  32.  
  33.  
  34.  

  [ You are not allowed to view this attachment ]  
  [ You are not allowed to view this attachment ]  


Demo here

Was eating dinner lol. But that is PERFECT. Thank you.