views:

231

answers:

5

Hello!

I'm developing an application which loads an image, and then i have to mark some points with the mouse, above the image. these points should be on a separate layer, ie i don't want to modify image data.

What is the best way of doing this ? I was thinking of using directX, but i've seen that it is a little bit obsolete. Does GDI+ resolves ?

Thanks in advance

+1  A: 

I think WPF have som options for image manipulation. It should be a lot more comfortable to work with than talking directly to directX.

Not directly what you are asking for, but this article might gice you some pointers (unless I totally misunderstand you).

http://www.codeproject.com/KB/WPF/ImageCropper.aspx

erikric
+3  A: 

DirectX would be an overkill, you should use GDI+ (aka, System.Drawing).

Eran Betzalel
+3  A: 

use BackgroundImage as priamry layer (OnPaintBackground override on the form) and OnPaint overrides the "main" layer with your points.

serhio
A: 

How about this?

<Border>
    <Border.Background>
        <ImageBrush ImageSource="foo.jpg" />
    </Border.Background>
    <Canvas Background="Transparent"/>
</Border>

Display the Image in the background and paint your points to an Canvas which lies on top of that image.

Edit: That would look like this in C#:

Border border = new Border();
Canvas canvas = new Canvas()
{
    Background = Brushes.Transparent
};
grid.AddChild(border);
border.Child = canvas;
border.Background = new ImageBrush();

Then you only need to load your image to the border.Backgound wrapped in an ImageBrush.

Marcel Benthin
This is in silverlight. Am I correct?
Himadri
It's XAML/WPF. But this should work in C# too.
Marcel Benthin
+1  A: 

Yes, GDI+ will be sufficient. All you need is to have two images:

  • One will contain background and will be "readonly";
  • Another will have no background and contain just the points you've drawn.

You will need just to draw one image over the other and then display the result to the user (mind using double buffering).

Although, I'll suggest to store the points not in a separate image but in a separate list, because you may need to do some processing with them later. So, suppose you are using buffer image, you'll need to draw the background on the buffer image then the points from the list and then display the result to the user.

I'll think about additional image for points only in terms of caching if needed.

Li0liQ