Recent

Author Topic: Timage is black  (Read 4495 times)

cov

  • Sr. Member
  • ****
  • Posts: 250
Timage is black
« on: November 28, 2006, 10:23:19 pm »
The following code floods the Image1 with black:

Code: [Select]

          bmapFile:=TBitmap.Create;
          bmapFile.LoadFromFile(OpenDialog1.Filename);
          Image1.Canvas.Draw(0,0,bMapFile);


It works in Delphi 3.

Anyone have any clue?

cov

  • Sr. Member
  • ****
  • Posts: 250
Timage is black
« Reply #1 on: November 29, 2006, 10:51:08 am »
Hi.

I needed to paint the rect with the background colour:

Code: [Select]

     Image1.Canvas.Brush.Color:=clWhite;
     Image1.Canvas.FillRect(0,0,BMapFile.Width,BMapFile.Height);

cov

  • Sr. Member
  • ****
  • Posts: 250
Timage is black
« Reply #2 on: November 29, 2006, 11:14:34 am »
But now another problem.

How can I pause my program until the image has been displayed.

I want to display the image first.

The I want to manipulate pixels in the image so that the process is visible to the user.

What's happening now is that the original image doesn't get time to be displayed so that there is no visual indication of what is going on until the process is complete, at which point the final image is displayed.

This is what I want:

Original Image...
pixels processed...
Altered Image...
more pixels processed...
Further Altered Image...
...
...
Final Image

This is what I'm getting:

.....
pixels processed...
....
more pixels processed...
....
...
...
Final Image

matthijs

  • Hero Member
  • *****
  • Posts: 537
Timage is black
« Reply #3 on: November 30, 2006, 08:12:23 am »
You should give the OS time to update the image. This would be possible by entering statements like
Code: [Select]

  YourImage.Invalidate;
  Application.ProcessMessages;

Invalidate well give a message that your Image needs repainting. ProcessMessage will give the OS time to react to those messages.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

 

TinyPortal © 2005-2018