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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

stewwi

@stewwi
About
Posts
4
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Bitmaps and Unsafe Code
    S stewwi

    erm yes that was it ! forgot about the alpha component :/ silly me :-O

    C# graphics help question

  • Bitmaps and Unsafe Code
    S stewwi

    i pasted only part of the code, the g.clear to fill the bitmap worked nicely just what i needed :) and basically im trying to build a spectograph so not every pixel is being drawn and everypixel i draw has a different weight :) thats why im going tthrough it pixel by pixel. the program is still in the early stages though thats why it may look a bit raw. Thanks a lot for your help ! :)

    C# graphics help question

  • Bitmaps and Unsafe Code
    S stewwi

    Sure i Create the bitmap here Bitmap pane = new Bitmap(800, 800); then i had to init the bitmap with a colour to get it working for (int i = 0; i < pane.Height; i++) { for (int j = 0; j < pane.Width; j++) { pane.SetPixel(j, i, Color.Black); } } basically i have to get rid of the code above then i use unsafe mode to set colours to individual pixels public Bitmap backup(Bitmap pane) { BitmapData panedata = pane.LockBits(new Rectangle(0, 0, pane.Width, pane.Height), ImageLockMode.ReadWrite, pane.PixelFormat); int stride = panedata.Stride; //returns the location of the first pixel of the image IntPtr Scan0 = panedata.Scan0; unsafe { byte* p = (byte*)(void*)Scan0; int nOffset = stride - pane.Height *3 ; int nWidth = pane.Width * 3; for (int y = 0; y < pane.Height; ++y) { for (int x = 0; x < pane.Width; ++x) { *(p + 0) = (byte)255; *(p + 1) = (byte)0; *(p + 2) = (byte)0; p += 4; } } } pane.UnlockBits(panedata); return pane; } like that it works but its takes ages to start

    C# graphics help question

  • Bitmaps and Unsafe Code
    S stewwi

    Hi all i have a small problem I am creating a new blank bitmap in a program, then using the lock bitmap i edit pixels. the Purpose iss to build a spectograph. Now my problem is that when i create the bitmap Bitmap pane = new Bitmap(800, 800); then edit it using pointers the image remains blank :doh: the only work around i could find is initialiazing the bitmap with setpixels one by one. This is obviously very slow and ive been trying to find a faster way :/ any suggetions ??

    C# graphics help question
  • Login

  • Don't have an account? Register

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