473,769 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

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

Similar topics

3
2379
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 "root-Canvas-Widget" for the color in position x,y like: color=cw.cget('bg',x,y) I need HELP :))
15
9078
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 the purpose of learning to work with C++. It therefore makes some sense for me to give the situation the amount of consideration presented below. To be quite honest, I'm amazed at the amount there is to say about such a seemingly simple...
3
5529
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 background of the cells in that column to their colors (which differ from row to row), but those background colors don't print unless a certain option is set in IE, which is apparently off by default. The way we've figured around this is to add a...
32
14893
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 ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
5
4708
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 rectangle that will allow the text to show through? I did try: myColor = Color.FromArgb(127, Color.GreenYellow) Dim fillBrush As New SolidBrush(myColor) but that isn't exactly the effect I wanted.
3
5077
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 support bi-level image. So I need this convert code to do this process, but it is not my study field. I try to view several website to write this code, but it can not work.
1
3820
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 convert a color image to a gray image in VB 2005. Thanks, Sugan Chennai, INDIA
3
1354
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) e.Graphics.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height) e.Graphics.DrawEllipse(texturedPen, 100, 20, 200, 100)
10
5469
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 cannot be done from starting from bottom-right to up-left. The only selection i'm allowed to do is starting from top-left towards bottom-right orientation. The code is:
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.