locked
just 1 pixel RRS feed

  • Question

  • Hello!
    I've got a such problem.
    I'd like to create a Drawingvisual object (for my bitmap image) which consists of different pixels (colors are in a text file). But I can't find how to create just a 1 pixel by using drawing visual.

    I need something like with:

                DrawingVisual drawingVisual = new DrawingVisual();

                DrawingContext drawingContext = drawingVisual.RenderOpen();

                drawingContext.DrawLine( DrawText(text, new Point(2, 2));

                drawingContext.Close();


    How can I create just a one pixel?
    Plz, help.

    Sry, if I choose a wrong part of forum.
    Monday, September 29, 2008 1:00 PM

Answers

  • DrawingContext is a geometric drawing environment that doesn't have the concept of a "pixel".  You could use DrawRectangle to draw a filled 1x1 rectangle, that's as close as you get.  But there's no guarantee that this will actually correspond to one pixel within your image.

    The WriteableBitmap class would be more appropriate if you want to manipulate the pixels of a bitmap image.

    • Proposed as answer by sirrocco Tuesday, September 30, 2008 8:46 AM
    • Marked as answer by Jim Zhou - MSFT Wednesday, October 1, 2008 9:41 AM
    Tuesday, September 30, 2008 7:13 AM

All replies

  • DrawingContext is a geometric drawing environment that doesn't have the concept of a "pixel".  You could use DrawRectangle to draw a filled 1x1 rectangle, that's as close as you get.  But there's no guarantee that this will actually correspond to one pixel within your image.

    The WriteableBitmap class would be more appropriate if you want to manipulate the pixels of a bitmap image.

    • Proposed as answer by sirrocco Tuesday, September 30, 2008 8:46 AM
    • Marked as answer by Jim Zhou - MSFT Wednesday, October 1, 2008 9:41 AM
    Tuesday, September 30, 2008 7:13 AM
  • Thanks a lot. It was really helpful!
    Tuesday, September 30, 2008 8:38 AM