Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Pixel Colour Replacement using C#

Posted on 2007-08-06
2
Medium Priority
?
619 Views
Last Modified: 2008-02-01
Hi all,

I am trying to do a search and replace on Pixel Colours within a bitmap in C# using the following:

for (int j = StartY; j <= StopY; j++)
{
   for (int i = StartX; i <= StopX; i++)
   {
      col = bmp.GetPixel(i, j);
      if (col == Color.FromArgb(255, 255, 255)) bmp.SetPixel(i, j, Color.Red);
      }
}

This works fine, but takes so long!!!!!

Are there any more efficient ways to do this?

Thanks,

James
0
Comment
Question by:James Atkin
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 19638409
Look at the iterating through pixels example here:

Iterating through the pixels
http://www.bobpowell.net/lockingbits.htm

Bob
0
 
LVL 4

Author Comment

by:James Atkin
ID: 19638707
Hi Bob,

Thanks for the reply.
I have just managed to get what I was after using a class called "FastBitmap".
http://www.gotdotnet.com/community/usersamples/details.aspx?sampleguid=6699aa41-7b59-40ec-a30d-da3afe63bd05

Points well earned anyway for a fast and efficient reply..

Best Regards,

James
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses

810 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