Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count pixels 1

Status
Not open for further replies.

jamesoc

Technical User
Feb 1, 2005
38
IE
i can count the amount of pixels in a textbox no prob but how would i count the pixels in a specific area of a picturebox
 
It depends what you mean by "a specific area".

If you set the PB measurement units to pixels (i.e. set .scalemode = 3), then its fairly straightforward. The properties .scaleheight and .scalewidth give you the height and width respectively of the PB in pixels. If your "specific area" is defined as a function of the total width and total height then just take the appropriate fraction. On the other hand, if your "specific area" is defined by, say, all the pixels whose red component is > 97, then loop through all the pixels in the PB using the .point function and count the ones which meet your criterion.

Note however that that will be a bit slow for lots of big pictures. Using API functions to set and get the bitmap bits associated with the PB is a lot faster.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top