Forum > GTK

GTK2 and StretchDraw.


I have a problem that I am sure is something I have overlooked but I can't seem to pin point it.

I have a component that when it is created it run the following procedure.
the FBmp variable is part of component's private section just copied it here to help the tests.

--- Code: ---procedure CreateRGBGradient;
  g, b: integer;
  FBmp : TBitmap=nil;
  if FBmp = nil then
    FBmp := TBitmap .Create;
    FBmp.PixelFormat := pf32bit;
    FBmp.Width := 256;
    FBmp.Height := 256;

  for g := 255 downto 0 do
    for b := 0 to 255 do
      FBmp.Canvas.Pixels[b,255-g] := RGB(FR, g, b);
  //FBmp.SaveToFile('D:\jkoz\Lazarus\Projects\To Convert\Components\mbColorLib\Test\RAxisColor.bmp');


--- End code ---

My custom component is based on TCustomControl and I have override the paint method with this one.

--- Code: ---begin
  Canvas.StretchDraw(ClientRect, FBmp);
  Canvas.StretchDraw(Rect(0, 0, Width, Height), FBmp);
//  Canvas.Brush.Color := clFuchsia;
//  canvas.Rectangle(0,0,100,100);
  CorrectCoords(mxx, myy);
  DrawMarker(mxx, myy);

--- End code ---

Everything works as expected with the windows widget set the image is rendered on the component and I can see it on my application. But if I change my compilation to use GTK2 nothing is rendered on the component just to make sure that I haven't step out of some boundaries I added the rectangle call and this rectangle is rendered and shown.
This tells me that there is something else I should be aware about GTK2 that I am not.

I'm attaching 3 files

* the bitmap that the commented out line in CreateRGBGradient procedure saved.
* The result of the current paint in GTK2
* The result of paint in Windows widget set
Any one can shed some light on the the problem?

Testing Environment
Lazarus 1.1 r38674 FPC 2.6.1 i386-win32-win32/win64

Sorry for the second post but I couldn't make the images any smaller and the forum soft did not allow me more than 250K of images.


I am attaching a small Test Case Project for you to try out.
When the application first starts it creates a fuchsia rectangle in the shape, after press create Bitmap button it should replace that rectangle with the bitmap whichcontains a gradient that is calculated on the fly. In windows widget set everything works as expected in GTK2 the bitmap never draws on the shape.

There is definitely something wrong with the bitmap. If I save it to a memory stream and then loaded again then everything works fine. There is something I am not setting that GTK needs to function properly.

Thank you in advance


[0] Message Index

Go to full version