473,372 Members | 1,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 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 1191

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Matthias | last post by:
Hello, I have a Canvas-Widget and will use as a "array of pixel". At Positon x,y I print a rectangle with a special color. I give the rectangle no objectname. Then I will ask the...
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
by: Vam | last post by:
Hi, My program makes an HTML report which needs to be easily printable. On this report is a table, and one of the columns in the table needs to express a color. I've done this by setting the...
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
by: DazedAndConfused | last post by:
I have a rectangle around text that I want to fill in with color. I do not know the height of the rectangle until I actually go through and draw out the text. Is there a way of filling in the...
by: ShihChengYu | last post by:
Dear all: How to convert color image to bi-level image? I have confronted one problem when I build my OCR project. I used an software API function to enhance my project, but the API only...
by: Sugan | last post by:
Hi all, I'm creating a custom button control. I need to show a color image when the button control is enabled and a gray shade of the same image when the button control is disabled. How can i...
by: reidarT | last post by:
I try to draw a rectangle in a form on a buttons click event, The code is Dim bitmap As New Bitmap("lysblaa.jpg") Dim tBrush As New TextureBrush(bitmap) Dim texturedPen As New Pen(tBrush, 30)...
by: kimiraikkonen | last post by:
Hi, If previous post was missing, here's the complete one: I'm trying to draw a rectange on a picturebox image using mouse move event but the problem is that the rectangle selection / drawing...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.