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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:39:40+00:00 2026-06-14T18:39:40+00:00

i am new in programming this kind of stuff and a search did not

  • 0

i am new in programming this kind of stuff and a search did not help me out. i found following code on the web and would need to modify it because this is giving me a overflowexception on toint32().

Any help appreciated! thanks

// lock bitmap data
BitmapData  bmData = img.LockBits(
new Rectangle(0, 0, width, height),
ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb);

// copy image data

int srcStride = bmData.Stride;
int dstStride = bmData.Stride;


      int dst = bmData.Scan0.ToInt32() + dstStride * (height - 1);
      int src = pBuffer.ToInt32();

                for (int y = 0; y < height; y++)
                {
                    Win32.memcpy(dst, src, srcStride);
                    dst -= dstStride;
                    src += srcStride;
                }

// unlock bitmap data
img.UnlockBits(bmData);
  • 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-06-14T18:39:42+00:00Added an answer on June 14, 2026 at 6:39 pm

    Scan0 is a pointer, using ToInt32() will overflow if you run in 64-bit mode. You must use ToInt64() and cast back to IntPtr. Your memcpy() declaration is wrong as well. Some handy declarations:

    private static IntPtr AddToPointer(IntPtr ptr, int offset) {
        return new IntPtr(ptr.ToInt64() + offset);
    }
    
    [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
    private static extern int memcpy(IntPtr dst, IntPtr src, int bytes);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a kind of a newb question but I'm really new to programming
i am enthusiast and new in programming trying this simple c language code and
i am new in programming under linux and trying to get working this code:
I've been attempting to figure this out for forever now (I'm new to programming)
i'm new to this kind of things. Kinda the first post ever regarding programming,
First, I am new to programming and this is my first major assignment in
i am new kernel programming.i have been trying to load this driver program for
Totally new to programming so kindly excuse the silly question. I have this URL
I read this story on slashdot today where they announce a new parallel programming
This question may seem daft (I'm a new to 'programming' and should probably stop

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.