Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm looking for the C++ version of the getpixel/setpixel functions of VB. I have a program in VB that's way too slow, so I'm trying to translate it into VC++. Basically it runs algorithms that edit an image pixel by pixel. It works fine in VB, but slow as mud.

So a) how do you access the rbg values of a selected pixel in a loaded image in Vc++, and b) how do you change them once you have the info?

Thanks in advance.
Posted
Comments
Sergey Alexandrovich Kryukov 29-Sep-11 20:09pm    
Windows? Tag it.
--SA

How many pixels you want to access? 5, 15? :-)

If you want to process a whole picture or a big part of them, forget GetPixel/SetPixel — this is too slow.
For a better approach, check out this CodeProject article: A fast way to work on Windows bitmap pixel data without using the slow GetPixel and SetPixel methods[^].

See also another article — a tutorial: Bitmap Basics - A GDI tutorial[^].

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 29-Sep-11 21:23pm    
Good points :)
Sergey Alexandrovich Kryukov 30-Sep-11 0:23am    
Thank you, Espen.
--SA
Abhinav S 1-Oct-11 5:40am    
Good answer. 5.
Sergey Alexandrovich Kryukov 1-Oct-11 9:07am    
Thank you, Abhinav.
--SA
You could take a look at the Anti-Grain Geometry Project[^]

It's quite good :)

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Abhinav S 1-Oct-11 5:40am    
Gives an alternate to the OP. 5.
Espen Harlinn 1-Oct-11 6:12am    
Thank you, Abhinav! AGG is really quite nice ...
have a look at The Bitmap Functions[^], specifically SetPixel
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900