1

I'm using two bitmaps to draw graphs on them. After drawing I need to show bitmap pictures in two Images. Assigning bitmap to Image or drawing bitmap to Image sometimes causes Image to disappear (you can see form background). I have tried this:

   Image->Picture->Bitmap->Assign(bitmap1);
   Image2->Picture->Bitmap->Assign(bitmap2);


   Image->Picture->Graphic = bitmap1;....


   Image->Canvas->Draw(0,0,bitmap1);....


   Image->Picture->Bitmap->Canvas->Draw(0,0,bitmap1);

If I don't have Sleep(100) between Image and Image2 redrawing, Image2 isn't visible for the most of the time. Also adding Image2->Refresh helps, but the issue still sometimes occurs to both Images.

If I save created bitmaps or Images to .jpeg files, all .jpeg images are correct and none of them are empty. Also Image->height, Image->picture->bitmap->height and width is always correct.

Can anyone tell me, what I'm doing wrong?

Pere Villega
  • 16,429
  • 5
  • 63
  • 100
Kobiic
  • 31
  • 6
  • I ended up using one image and one bitmap, which greatly increased chance, that image don't disappear. Is there a chance, that it might be caused by amount of data, that need to be drawn? As in http://stackoverflow.com/questions/10168792/image-is-disappearing-with-rotation-in-osg answer? – Kobiic Aug 22 '12 at 09:58

1 Answers1

1

After a while I realised, that bitmaps and Images, which I saved, weren't all correct. If I was unable to see picture, it wasn't fully drawn. There were no errors, it occurred randomly, but I found out, that once program started to ignore my drawing commands, it didn't draw anything until the end of the function, which does drawing. So - to check, if I can still draw, before assigning bitmap to Image, I did this:

            Image3->Canvas->Pixels[y][0] = clRed;
            TColor test =  Image3->Canvas->Pixels[y][0];

            Image3->Canvas->TextOut(y, 0, Device1->name);

            TColor test2 = Image3->Canvas->Pixels[y][0];

            if(test == test2)
            {
                    imageUpdated = false;
                    delete Image3;
                    return;
            }

            Image->Picture->Graphic = Image3;
            imageUpdated = true;

It means - I changed one pixel red, and after that printed over text, which should make that changed pixel white. Based on that I checked, if the color changed (was able to change pixel color and print text).

I really don't know reason, why it sometimes starts to ignore drawing commands, but I hope, that if someone runs into the same issue as I did, this answer might help him/her.

Kobiic
  • 31
  • 6