October 25, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Image Negations

  • November 19, 2002
  • By Developer.com Staff
  • Send Email »
  • More Articles »

The Basic Principle of Making neagtive image from a normal one involves complimenting colors.The process of complementing involves representing colors in a three dimensional cube with the basic colors RGB as the three axis of the cube. When all colors are represented in a cube the opposite corners represent the Complement of the color.

Complement of white is black, complement of blue is yellow. Complementing can be done using the RGB combination.

white rgb(255,255,255)

The complement of white can be obtained by rgb(255-255,255-255,255-255) which has rgb(0,0,0) which is black.

The same concept as above is used in the program but just converted the integers to hexadecimal for the ease of calculation.

For i = 0 To Picturebox.ScaleHeight - 1
    For j = 0 To Picturebox.ScaleWidth - 1
      pixvalue = Picturebox.Point(j, i)
      hex_pixval = Hex(pixvalue)
      red_val = "&h" & Mid$(hex_pixval, 5, 2)
      green_val = "&h" & Mid$(hex_pixval, 3, 2)
      blue_val = "&h" & Mid$(hex_pixval, 1, 2)

      If red_val = "&h" Then red_val = "&h0"
      If green_val = "&h" Then green_val = "&h0"
      If blue_val = "&h" Then blue_val = "&h0"

      red_val = &HFF - red_val
      green_val = &HFF - green_val
      blue_val = &HFF - blue_val

      Picturebox.PSet (j, i), RGB(red_val, green_val, blue_val)
    Next
Next






Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel