Ooops
March 01, 2021, 10:37:29 PM

Author Topic: [bb] Color2Grayscale by Matt Merkulov [ 1+ years ago ]  (Read 460 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Color2Grayscale by Matt Merkulov [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Color2Grayscale
Author : Matt Merkulov
Posted : 1+ years ago

Description : From <a href="http://blitzetcetera.org/" target="_blank">Blitz et cetera[/url] article
Image used:


Code :
Code: BlitzBasic
  1. ;Color2Grayscale by Matt Merkulov
  2.  
  3. Graphics 640,480,32
  4.  
  5. i=LoadImage ("image1.jpg")
  6. DrawBlock i, 0,0
  7.  
  8. For y = 0 To 479
  9.  For x = 0 To 639
  10.   p = ReadPixel(x, y)
  11.   b = p And 255
  12.   g = (p Shr 8) And 255
  13.   r = (p Shr 16) And 255
  14.   c = .3 * r + .59 * g + .11 * b
  15.   WritePixel x, y, c + c Shl 8 + c Shl 16 - 16777216
  16.  Next
  17. Next
  18.  
  19. WaitKey


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal