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

  • SEARCH
  • Home
  • 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
  • 1 View
  • 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'm writing a drawing application that includes shapes that can have children. When I
I have been developing the application for drawing, and there is the code: public
I have been developing the application for drawing, and there is the following code
In my WPF application I have a Canvas in which I do some drawing.
in a simple drawing application I have a model which has a NSMutableArray curvedPaths
We have pretty much C# 2.0 code that heavily relies on System.Drawing namespace. Also
I have a VB.NET WinForms application. I am drawing a bunch of shapes on
I am writing a GLPaint-esque drawing application for the iPad, however I have hit
I am creating a simple drawing application in which I have a UIView in

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.