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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:55:37+00:00 2026-05-16T22:55:37+00:00

I have a 2208 x 3000 TransformedBitmap object with format {Indexed8} that I’m do

  • 0

I have a 2208 x 3000 TransformedBitmap object with format {Indexed8} that I’m do .CopyPixels() on. I’m using

(int)((formattedBitmap.PixelWidth * formattedBitmap.Format.BitsPerPixel + 7) / 8)

(assuming ‘formattedBitmap’ is the name of the image from which I’m trying to copy the pixels) for the ‘stride’ value in my method call and an array of bytes which is 2208 in length. I have something just like this working elsewhere in the code (where the format of the image is {Gray8}. However, where I’m trying to do this same thing on the aforementioned image, I continually get an “Argument Out of Range” exception saying “The parameter value cannot be less than ‘6624000’.\r\nParameter name: buffer.”

My questions about this are: why in the world does the exact same code seem to work in one place and not the other? What in the world, in layman’s terms, really IS the ‘stride’? And how can I get the desired affect (of copying the bits) without getting this error? What am I doing wrong?

Any help to this would be very much appreciated. Thanks a lot!

  • 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-16T22:55:37+00:00Added an answer on May 16, 2026 at 10:55 pm

    I’ve figured this out (wow…kinda can’t believe I spent something nigh an hour messing with this!). The problem was that the byte array has to be of size

    sourceImage.PixelHeight * stride
    

    where

    int stride = (int)((sourceImage.PixelWidth * sourceImage.Format.BitsPerPixel + 7) / 8);
    

    The reason that it worked in the other location in my code is because rather than copying the pixels for the entire image (as I’m trying to do where I was having the issue), I was only copying the pixels of a single row…that is, basically a 2008 x 1 area, so that the size of the destination byte array could be exactly 2208 and it would work fine. For future reference, something like this should probably always, more or less, be used:

    int width = source.PixelWidth;
    int height = source.PixelHeight;
    int stride = width * ((source.Format.BitsPerPixel + 7) / 8);
    
    byte[] bits = new byte[height * stride];
    
    source.CopyPixels(bits, stride, 0);
    

    Cheers!

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

Sidebar

Related Questions

No related questions found

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.