How To, length of image bar.

Zumwalt
01-06-2005, 09:28 AM
I have a jpg image, that has multiple bars on it with different lengths, I am trying to determine the length of the bar or the 'filled' area.

I want to write a little application that can look at the entire image with the bars, and change the bars to values.

The bars are a constant width (total bar size), and there a constant height.

Wich api would I use or how would I go about getting the length of the filled in area?

I thought there might already be code out there to do this, but I can't find any, and I don't know where or how to begin.

Thanks ahead of time.

Zumwalt
01-06-2005, 11:46 AM
As it stands I can work through the given bmp files and locate the objects I am looking for, the bars in the object are attached.

zelg37
01-07-2005, 12:46 AM
You should use LoadPicture to load the jpeg image into a picturebox control and then use the GetPixel API to read the pixel colors of the bar.

The white-ish part of each bar (in the "clone.bmp" image) is anti-aliased and
you may have to specify a range of colors to find the length.

Note: Your attached bmp was not readable in MsPaint, PaintShopPro, or Fireworks - very weird (all said "invalid bmp format"). I had to use Photo Editor see the image, so I will attach a more standard bmp file (as well as as a gif) for others who may want to take a look.

Zumwalt
01-07-2005, 08:48 AM
Thanks for the suggestion, it was the direction I was looking for, I ended up using vb.net 2002, and wrote a few controls, first control reads in the bitmap and cleans out the odd green color and sets it to transparant (A=0, R=0, B=0, G=0)

Then I took and walked through the image line by line and found where R>=220, B>=220, G>=220, and walked horizontally through this, after all my initial filters and cleaning process was finished, the resulting images for each bar was 1 pixel high, and different lengths (well there original lengths, not changed by the filter)

The max length in pixel for each bar is only 60 px wide, no matter the screen resolution I used.

I took the pixel count in width, / 60, then multiplied the result by 100, finally took that and did a decimal.round(result,0)

This is working wonderfully with getpixel, and I used setpixel to flush the junk I didn't need to transparent.

Thanks for showing me the direction I needed to take.

Edit:
If there is an easier way then what I described, please let me know.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum