By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

Search single color rectangle in a bitmap and get position and dimensions

P: n/a
Hi,

first, I want to apologize for any bad english that might be following
and lead to none or bad understanding of my posting. It has been a long
time since I last posted in english ;-)

So far I haven't dealt much with graphics programmming except drawing a
line on a hwnd or similar simple tasks.

Now I actually have a problem that I couldn't solve by searching Google
and my usual research approaches.

Problem:

An existing bitmap (24-bit color) shows a "border", i.e. a TFT-Monitor
or window. The rectangle is in this bitmap, prepared with a perfectly
solid color at the place where I need to draw into. Since users can have
different screen resolutions and I don't want to hardcode the positions
for every image and might support user-defined (prepared) bitmaps in
future, I need to scan the bitmap for such an rectangle.

Goal:

I need to determine the position and dimensions of the solid colored
rectangle to be able to draw into it.

My thinkings:

Since there will only be one solid colored rectangle in such a bitmap,
my in-mind-builded logically solution is to scan the bitmap with a small
RECT pixelwise:

1. Use a loop and position RECT pixel-by-pixel from left to right
2. If bottom or left side of the RECT consist of one color completely,
I've found a beginning
3. Now I can position downwards until the upper side of the RECT also
has the solid color, etc.

Well, I'm nearly sure this way it might be incredibly slow, so I even
didn't try to code it...

Has anyone a better advice or piece of code, so I can solve this problem
as performant as possible?
Thank you,

Mathias Wuehrmann

Apr 7 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.