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
C

CopperCircle

@CopperCircle
About
Posts
11
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How can I get input from 2 forms?
    C CopperCircle

    Hi, I have two forms that both open windows, I need to get the response from a checkbox on Form2 and use it with Form1, Form2 is not a dialogue and needs to open all the time. Any ideas? Thanks.

    C# question

  • And operator in c#?
    C CopperCircle

    Hi, I am trying to convert some of my BlitzBasic code over to C# and I cant get the following statment to work? Blitz: If paletteRmap[i]=0 And paletteGmap[i]=0 And paletteBmap[i]=0 C#: If (paletteRmap[best]=0 & paletteGmap[best]=0 & paletteBmap[best]=0) Error Message The left-hand side of an assignment must be a variable, property or indexer? Thanks.

    C# csharp help question

  • How can I copy a block of memory?
    C CopperCircle

    Hi, I found a very quick method in the end using RtlMoveMemory:

    [DllImport("kernel32")]
    public static extern void RtlMoveMemory(IntPtr dest, IntPtr src, int len);

    System.IntPtr pBuffer2 = Marshal.AllocHGlobal(BufferSize); //Assign unmanaged memory
    RtlMoveMemory(pBuffer2, pBuffer, BufferSize); //Copy memory
    byte* p2 = (byte*)(void*)pBuffer2;
    // Use p2 to access image pixels
    Marshal.FreeHGlobal(pBuffer2); //Free unmanaged memory

    Thanks, for the help and hope this helps some one else.

    C# question csharp data-structures performance

  • How can I copy a block of memory?
    C CopperCircle

    Thanks, I tried to use Marshal.Copy but I could not get it to work, could you please show how to implement it? Cheers,

    C# question csharp data-structures performance

  • How can I copy a block of memory?
    C CopperCircle

    Thanks, I got it to work, but there must be an faster/easyer way to copy a block of memory? This is what I did to get it to work with Marshal.ReadByte, it gives me p2 which I can use on the copied image:

    byte[] bytes = new byte[BufferSize];
    for (int i = 0; i < BufferSize; i++)
    bytes[i] = Marshal.ReadByte(pBuffer, i);

    fixed (byte* pTmp = bytes)
    {
    System.IntPtr pBuffer2 = new IntPtr((void*)pTmp);
    byte* p2 = (byte*)(void*)pBuffer2;
    }

    C# question csharp data-structures performance

  • How can I copy a block of memory?
    C CopperCircle

    Thanks for the reply, I am very new to C# and I am just working off the Videocog tutorials, do you have an example of how Marshal.Copy works?

    C# question csharp data-structures performance

  • How can I copy a block of memory?
    C CopperCircle

    Hi, I am trying to use the third party VideoCog componet with C# and I need to copy a image frame? Videocog drops the frame into an rgb array in memory and I can then fast process the pixels using pointers. How can I create another copy of the frame from memory so that I can also access that via another pointer? Thanks...

    1. private void videoCogControl1_FrameReady(double SampleTime, IntPtr pBuffer,
    2.                                      int BufferSize, int Width, int Height)
      
    3.  {
      
    4.       unsafe
      
    5.       {
      
    6.            byte\* p = (byte\*)(void\*)pBuffer;
      
    7.            int nWidth = Width \* 3;
      
    8.            for (int y = 0; y < Height; y++)
      
    9.            {
      
    10.                 for (int x = 0; x < nWidth; x++)
      
    11.                 {
      
    12.                     p\[0\] = (byte)(255 - p\[0\]);
      
    13.                     p++;
      
    14.                 }
      
    15.            }
      
    16.        }   
      
    17.  }
      
    C# question csharp data-structures performance

  • How can I copy a block of memory?
    C CopperCircle

    Hi, I have an image in memory as an RGB array, I need to make a fast copy of it? I access the image in usafe mode using the following pointer byte* p = (byte*)(void*)pBuffer; I need another copy of the data so that I can create a new pointer to it and leave my origional data unaffected. Thanks...

    C# question data-structures performance

  • How to navigate memory using pointers?
    C CopperCircle

    Hi, the problem is I have only used Blitz Basic before and I could jump to a pixel, eg GetColor(129,280)"Width,Height", with pointers I have to scan along the image for the data, I dont know how to jump to the pixel data I want?

    C# csharp performance tutorial question lounge

  • How to navigate memory using pointers?
    C CopperCircle

    Hi, I am very new to C# but I am modifying an image buffer directly within memory, I am scanning along moving the pointer to get the RGB of each pixel, but I need away to jump around the image memory and read the pixels at random rather than just p++ or p--? Thanks...

      unsafe 
                { 
                    byte\* p = (byte\*)(void\*)pBuffer;
                    for(int y = 0; y < Height; y++)
                    {
                        for(int x = 0; x < Width; x++)
                        {
                            //B
                            int srcB = p\[0\];
                            p++;
                            //G
                            int srcG = p\[0\];
                            p++;
                            //R
                            int srcR = p\[0\];
                            p++;
                        }
                    }
                }
    
    C# csharp performance tutorial question lounge

  • How to get a RGB values from an image buffer?
    C CopperCircle

    Hi, I am new to C# and im working trying some image processing, im using this bit of code to invert the pixels on an image grabbed from a video file, how do I extract the RGB values from a pixel in C# using the image buffer? Speed is of the essence... Thanks in advance.

    unsafe
    {
    byte* p = (byte *)(void *)pBuffer;
    int nWidth = Width * 3;
    for(int y = 0; y < Height; y++)
    {
    for(int x = 0; x < nWidth; x++ )
    {
    p[0] = (byte)(255-p[0]);
    p++;

    C# question csharp performance tutorial
  • Login

  • Don't have an account? Register

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