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 444679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:17:41+00:00 2026-05-12T21:17:41+00:00

unfortunately I cannot resort to C# in my current project, so I’ll have to

  • 0

unfortunately I cannot resort to C# in my current project, so I’ll have to solve this without the unsafe keyword.

I’ve got a bitmap, and I need to access the pixels and channel values directly. I’d like to go beyond Marshal.ReadByte() and Marshal.WriteByte() (and definitely beyond GetPixel and SetPixel).

Is there a way to put all the pixel data of the bitmap into a Byte array that works on both 32 and 64 bit systems? I want the exact same layout as the original bitmap, so the padding for each row (if it exists) also needs to be included.

Marshal doesn’t seem to have something akin to:

byte[] ReadBytes(IntPtr start, int offset, int count)

Unless I totally missed it…

Any help greatly appreciated,
David

ps. So far all my images are in 32BppPArgb pixelformat.

  • 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-12T21:17:41+00:00Added an answer on May 12, 2026 at 9:17 pm

    Marshal does have a Method that does exactly what you are asking. See Marshall.Copy()

    public static void Copy(
        IntPtr source,
        byte[] destination,
        int startIndex,
        int length
       )
    

    Copies data from an unmanaged memory
    pointer to a managed 8-bit unsigned
    integer array.

    And there are overloads to go the other direction as well

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

Sidebar

Related Questions

One of our developers used this call: TzSpecificLocalTimeToSystemTime() but unfortunately we cannot keep it
My HTML looks something like this (unfortunately it cannot change because it is being
I have these awkward checkboxes and unfortunately I cannot rename them the same due
I have a free Wordpress blog, which unfortunately I cannot use plug-ins to colour
I have a Drupal site using jQuery 1.3, so that unfortunately I cannot use
I need to get contents of a b tag and unfortunately I cannot change
Unfortunately I cannot reliably reproduce this error but infrequently I get it and occasionally
here's what I currently have, unfortunately I cannot seem to figure out how to
I am trying to remove all HTML elements from a String. Unfortunately, I cannot
Unfortunately I am not writing this question from my Developing PC so I might

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.