Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3217198
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:23:00+00:00 2026-05-17T15:23:00+00:00

I have a drawing application developed in winforms C# which uses many System.Drawing.Bitmap object

  • 0

I have a drawing application developed in winforms C# which uses many System.Drawing.Bitmap object throughout the code.

Now I am writing it into WPF with c#. I have done almost 90% of the conversion.

Coming to the problem… I have the following code which is used to traverse the image pixel by pixel

Bitmap result = new Bitmap(img); // img is of System.Drawing.Image
result.SetResolution(img.HorizontalResolution, img.VerticalResolution);
BitmapData bmpData = result.LockBits(new Rectangle(0, 0, result.Width, result.Height), ImageLockMode.ReadWrite, img.PixelFormat);

int pixelBytes = System.Drawing.Image.GetPixelFormatSize(img.PixelFormat) / 8;
System.IntPtr ptr = bmpData.Scan0;

int size = bmpData.Stride * result.Height;
byte[] pixels = new byte[size];

int index = 0;
double R = 0;
double G = 0;
double B = 0;

System.Runtime.InteropServices.Marshal.Copy(ptr, pixels, 0, size);

for (int row = 0; row <= result.Height - 1; row++)
  {
   for (int col = 0; col <= result.Width - 1; col++)
   {
     index = (row * bmpData.Stride) + (col * pixelBytes);
     R = pixels[index + 2];
     G = pixels[index + 1];
     B = pixels[index + 0];
    .
    .// logic code
    .
    }
  }

result.UnlockBits(bmpData); 

It uses System.Drawing’s for the purpose.

Is it possible to achieve this thing in wpf as well keeping it simple as it is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:23:00+00:00Added an answer on May 17, 2026 at 3:23 pm

    In addtion to Chris’s anwser you might want to look at WriteableBitmap. It’s another way to manipulate images pixels.
    Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed application for drawing some shapes (lines mostly) , now i need
I have an object of the type System.Drawing.Image and want to make every pixel
I have an application that writes text onto images using System.Drawing (C#). I am
I have a little paint application which was based on the GLPaint sample code.
I have a Winforms application that the user uses to take a region based
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Consider i have a window Application,developed in Visual Studio 2005, having a button. I
I have developed a quite large application using MFC. Naturaly, I used GDI for
I have started developing a drawing application in as3. I am thinking that I
I have a prototype of a simple drawing application. When the user drags a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.