471,854 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,854 software developers and data experts.

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


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.


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.


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
0 1150

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Matthias | last post: by
15 posts views Thread by Steven T. Hatton | last post: by
3 posts views Thread by Vam | last post: by
32 posts views Thread by tshad | last post: by
5 posts views Thread by DazedAndConfused | last post: by
3 posts views Thread by ShihChengYu | last post: by
3 posts views Thread by reidarT | last post: by
10 posts views Thread by kimiraikkonen | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.