Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C#.net error: Attempt to read or write protected memory or often this is the indication that other memory is currupt

C#.net error: Attempt to read or write protected memory or often this is the indication that other memory is currupt

Scheduled Pinned Locked Moved C#
csharpgraphicsdatabasewinformsdata-structures
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rao Rafique
    wrote on last edited by
    #1

    the code that causes error is boldfaced...see below the inner most loop code. private void toolStripButton3_Click(object sender, EventArgs e) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// GDI+ still lies to us - the return format is BGR, NOT RGB. ///Cover Image Code Bitmap bmp1 = new Bitmap(textBox1.Text); ///takes image from openfiledlg textbox1 ///takes an object of BitmapData & apply LocBits() BitmapData bmp1data = bmp1.LockBits(new Rectangle(0, 0, bmp1.Width, bmp1.Height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb); ///finds out Bitmap's stride int stride1 = bmp1data.Stride; ///defines pointer's to scan0 (1st byte of BimapData array System.IntPtr Scan1 = bmp1data.Scan0; ///end of Cover Image Code /////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// /// Stego Image code Bitmap bmp2 = new Bitmap("f:\\bb.jpg"); BitmapData bmp2data = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); int stride2 = bmp2data.Stride; System.IntPtr Scan2 = bmp2data.Scan0; unsafe { ///unsafe stego code byte* ptr2 = (byte*)(void*)Scan2; int offset2 = stride2 - bmp2.Width * 3; byte b2; ///end of unsafe stego //////////////////////////////////////////////////////////////// ///unsafe cover code /// defines a byte type pointer to scan0 byte* ptr1 = null; ptr1 = (byte*)(void*)Scan1; /// finds offset of the BitmapData int offset1 = stride1 - bmp1.Width * 3; /// defines RGB values byte b1,index=0; bool bitt; int x1, x2, y1, y2; ///iterates through the BitmapData ///end of unsafe cover code //////////////////////////////////////////////////////////////// for (y2 = 0; y2

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups