• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Canvas.Pixels + ImagingBitmap

Started by davem, 20 April 2010, 09:48:03

Previous topic - Next topic

davem

  I got very interesting problem. I manipulate an image using TImageData however then I need to add a text and modify a few pixels manually. So I do this:

        ImgBitmap:=TImagingBitmap.Create;
        ImgBitmap.AssignFromImageData(MainImage);

        // add text (just an example)
        ImgBitmap.Canvas.TextOut(x,y,'some text');

        // set some colors (just an example)
        ImgBitmap.Canvas.Pixels[x,y]:=col;

        // save the changes back to ImageData
        ImgBitmap.AssignToImageData(MainImage);
        ImgBitmap.Free;

  However, my problem is that in some cases (let's say every fifth case) the changes of colors are not visible on the picture when I save it. It seems to me that the Canvas/Handle hasn't been updated yet at the moment I assign the bitmap back to ImageData. Sometimes the part of the image is even partially black. Does anyone have any idea what can be done? I tried to put sleep behind, I tried to use a CriticalSection (it is multithreading appl), I tried to Lock the canvas (although the ImgBitmap is not shared) however nothing works. I also tried to run only one thread but it was the same. Does anyone have any idea?

davem

Hmm, Synchronize seems to solve the issue. But I don't know why.  :-\

Galfar

What about calling Canvas.Release or Canvas.Refresh after the pixels are set?

davem

Quote from: Galfar on 20 April 2010, 15:33:20
What about calling Canvas.Release or Canvas.Refresh after the pixels are set?


Canvas.Refresh did not help. I haven't tried Canvas.Release.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk