December 03, 2020, 08:19:02 PM

Author Topic: [bb] Image color FX by Matt Merkulov [ 1+ years ago ]  (Read 445 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Image color FX by Matt Merkulov [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Image color FX
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. ;Image color FX by Matt Merkulov
  2.  
  3. Const k# = 180.0 / 255, k2# = 360.0 / 255, fx = 2
  4. Dim col(2)
  5.  
  6. Graphics 640,480,32
  7.  
  8. i=LoadImage ("image1.jpg")
  9. DrawBlock i, 0,0
  10. For y=0 To 479
  11.  For x=0 To 639
  12.  p = ReadPixel (x, y)
  13.  For n = 0 To 2
  14.   c = p And 255
  15.   p = p Shr 8
  16.   Select fx
  17.   Case 1; Negative
  18.    c = 255 - c
  19.   Case 2; Darkening
  20.    c = c Shr 1
  21.   Case 3; Lightening
  22.    c = 128 + (c Sar 1)
  23.   Case 4; Threshold
  24.    c = 255 * (c >= 128)
  25.   Case 5; Saturation reduction
  26.    c = 64 + (c Sar 1)
  27.   Case 6; Saturation increase
  28.    c = c Shl 1 - 128
  29.    If c < 0 Then c = 0
  30.    If c > 255 Then c = 255
  31.   Case 7; Square-law darkening
  32.    c = 255 - Sqr(255 * 255 - c * c)
  33.   Case 8; Square-law lightening
  34.    c = 255 - c
  35.    c = Sqr(255 * 255 - c * c)
  36.   Case 9; Colors quantity reduction
  37.    c = Int(c / 51) * 51
  38.   Case 10; Saw
  39.    c = (c Shr 6) * 4
  40.   Case 11; Sawtooth
  41.    If c And 64 Then c = 255 - (c And 63) * 4 Else c = (c And 63) * 4
  42.   Case 12; Hollow
  43.    c = 255 * (1 - Sin(c * k#))
  44.   Case 13; Ledge
  45.    c = 255 * Sin(c * k#)
  46.   Case 14; Bend
  47.    c = Sin(c * k2#) * 127 + c
  48.   End Select
  49.   col(n) =c
  50.  Next
  51.  WritePixel x, y, col(0) + col(1) Shl 8 + col(2) Shl 16 - 16777216
  52.  Next
  53. Next
  54.  
  55. WaitKey


Comments :


Andy_A(Posted 1+ years ago)

 Thanks Matjev,The routines seem to work fine. Don't really know what "the Saw","the Hollow","the Ledge","the Bend","Zubya" mean.Try using simple words to describe then translate to English.Here's another tranlator site: <a href="http://webtranslation.imtranslator.net/" target="_blank">http://webtranslation.imtranslator.net/[/url]


Matt Merkulov(Posted 1+ years ago)

 Take look at the graphs:In fact, they're just funny fx, maybe not so useful as standard.


Andy_A(Posted 1+ years ago)

 They are some of the same effects used in GIMP and Photoshop. Not the same code, but same effects, so they could be useful to someone.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal