QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Craz1000 on January 02, 2021, 05:39:15 pm

Title: Black and White
Post by: Craz1000 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?

Title: Re: Black and White
Post by: bplus on January 02, 2021, 05:55:02 pm
I would colorize the version. :)
Title: Re: Black and White
Post by: Craz1000 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.
Title: Re: Black and White
Post by: bplus 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?
Title: Re: Black and White
Post by: Cobalt 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.
Title: Re: Black and White
Post by: bplus 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.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

   [ This attachment cannot be displayed inline in 'Print Page' view ]  



Demo here

Oops! ziped folder before saved bas file, fixed zip now.
Title: Re: Black and White
Post by: Craz1000 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.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
  [ This attachment cannot be displayed inline in 'Print Page' view ]  


Demo here

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