Colour map implemented as a bitmap

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EARNEST
    New Member
    • Feb 2010
    • 128

    Colour map implemented as a bitmap

    Hello there,
    I would like to create N x M colour map, pixel at location(a,b) would be of certain colour based on certain range of values of double/integer filters. The trick is that it would have like 70*50 pixels that would change their colors very fast (depending on those double filters). I implemented it as a bitmap.

    Code:
    for loop i
    {
    for loop j
    {
    myColorMap.SetPixel(i, j, Color);
    }
    }
    Is it efficient? Are there any better implementations ?
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Honestly, I don't know how efficient this implementation is. I think a bitmap like that lives in memory so it shouldn't be terribly slow, but there's also a good chance it doesn't use your graphics card to handle the drawing, which may be slow.

    You could give GDI+ a try (though I'm not sure how fast that is either), or you could look at embedding an XNA game object (google these terms :D) into your form and use that to draw, where you can either use a Texture2D object as your color map (manipulate the Texture2D data, which is a 2D array of Color) or use a 1x1 pixel texture with SpriteBatch.Dra w to serve as a "pixel".

    If it were me, I'd try a bunch of different methods to see what gave you the performance you were looking for :)

    Comment

    • EARNEST
      New Member
      • Feb 2010
      • 128

      #3
      Hm, totally forgot about Sprites for 2d...thats a good idea. I'll give it a try, but need to do more research, not that good with CG and XNA. Thanks a lot.

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        I should add that manipulating the color data for a Texture2D object is probably no different than writing to an in-memory bitmap like you're already doing. It's just that the draw itself might be a little faster.

        Comment

        Working...