[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

HARD!! getting/changing data in bitmap image

Posted on 2003-10-21
13
Medium Priority
?
264 Views
Last Modified: 2012-06-27
Hi experts,
     I have a question that should set you thinking.

     I have a bitmap(a picute I took with a digital camera) that has some writing on it, well its a picture of some writing.  The problem with the photo is that the background is a kind of yucky grey/brown colour, though i wrote it on a clean WHITE peice of paper.

I want to write a program that makes the background colour a colour of the users choice.

I don't even know where to start writeing this, can some one help?

thanx,
     Boyidiot
0
Comment
Question by:Boyidiot
  • 7
  • 4
  • 2
13 Comments
 

Assisted Solution

by:eliaslopezgtz
eliaslopezgtz earned 200 total points
ID: 9595227
try using the win32 api...
setpixel... getpixel...
that would be the fastest way to do ...
but you need to get used to handles.. and things like that...
0
 

Author Comment

by:Boyidiot
ID: 9595275
yes I could do that I could get the user to select the back colour on the picture then change/blankout all the pixels with that colour, but the background colour isn't the same colour.

hmmm, I could get the user to select the text colour(at its lightest), then only keep the pixels that are darker than it.

Could you help me put it into code, I dont know how to use Setpixel/getpixel.
thanx

 Boyidiot
0
 

Expert Comment

by:eliaslopezgtz
ID: 9595400
Public Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Public Type POINTAPI
    x As Long
    y As Long
End Type

this are the declarations
let me write some samples wait a sec...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:eliaslopezgtz
ID: 9595408
Private Sub draw_MouseDown(button As Integer, Shift As Integer, x As Single, y As Single)
    If button = vbLeftButton Then draw.FillColor = col1.BackColor
    If button = vbRightButton Then draw.FillColor = col2.BackColor
    Dim m As POINTAPI
    m.x = x / 15
    m.y = y / 15
    p = GetPixel(draw.hdc, m.x, m.y)
    ExtFloodFill draw.hdc, m.x, m.y, p, 1
    draw.Refresh
end sub
0
 
LVL 10

Accepted Solution

by:
cool12399 earned 200 total points
ID: 9600471
Also...

Just so you are aware -- the programming task will be a little more challenging than you think,
you will either need a little bit of mathematics background, or someone who does. The image
will not have a 'uniform' yellow color, so you will have to test for tolerance as well if you use
some kind of flood fill routine, which means you'll have to write your own routine to make it
look right. Otherwise -- what you'll see -- is basically an image, still with some yellow, and some
of the yellow pixels whited out. And you can't simply change all 'yellow' pixels, in case the 'image'
has yellow color in it...

So it'll be a little harder than you expect.
0
 

Author Comment

by:Boyidiot
ID: 9603734
thanx for the advice, I'm gonna make sure though that the write be in black/blue, a dark colour.

'you will either need a little bit of mathematics background'- How much?

0
 

Expert Comment

by:eliaslopezgtz
ID: 9607388
or maybe if you want...
http://graphics.lcs.mit.edu/classes/6.837/F00/Lecture04/

best regards and don't forget to accept an answer
0
 

Author Comment

by:Boyidiot
ID: 9609832
I wont forget, I'm just gonna give it another couple of days or so
0
 
LVL 10

Expert Comment

by:cool12399
ID: 9610148
how about giving me the points?? :)
now *theres* good advice!

to do it correctly (make it look good), you will either need a fair amount, or
hire someone skilled to do it. a simple flood fill will not work (will only do adjacent pixels
of the same color).

0
 

Expert Comment

by:eliaslopezgtz
ID: 9610380
you are right... help us please
0
 

Author Comment

by:Boyidiot
ID: 9620675
well I've done it, it just needs abit of tunig to get it perfect, but I DID IT!!!

heres how,

i've got two pictureboxes one with the picture in it. then the user selects a colour, It splits that colour into RGB, then the program gram goes through each pixel(about 10000 a second) and sees if its darker or lighter than the set colour. If it is darker it transfers it to the other picturebox.

well thanx guys
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question