VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Explains How to convert images to Negative using Paintpicture

by manikantan (12 Submissions)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 25th October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Explains How to convert images to Negative using Paintpicture

Rate Explains How to convert images to Negative using Paintpicture




Manikantan
3rd Agenda,
Web Development,
India.
Website:www.3rdagenda.com
Email:[email protected]


Complementing Images.

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 bee
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

With the above Code snippet U can Convert an image to its Negative
Article by Manikantan
Email:[email protected]

Download this snippet    Add to My Saved Code

Explains How to convert images to Negative using Paintpicture Comments

No comments have been posted about Explains How to convert images to Negative using Paintpicture. Why not be the first to post a comment about Explains How to convert images to Negative using Paintpicture.

Post your comment

Subject:
Message:
0/1000 characters