Solved

HARD!! getting/changing data in bitmap image

Posted on 2003-10-21
13
236 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 100 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
 

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
 

Expert Comment

by:eliaslopezgtz
ID: 9595412
0
 
LVL 10

Accepted Solution

by:
cool12399 earned 100 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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: 9607351
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

912 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now