I am getting unexpected results when using Draw_Image with a canvas that has 
been resized to match the size of the IMG that is being drawn in it. The 
attached program demonstrates the behavior. Different initial sizes of the 
canvas can be used by selecting one of the Create calls, and one of the two 
Draw_Image procedures may be selected.
When the canvas' initial size is not the same as the size of the image, the 
contents of the canvas are not the same as those of the image. If the canvas is 
created the same size as the image, then the canvas and the image are identical.
Possibly this is the correct behavior, but in that case I would like to know 
how to get a resized canvas to have the same contents as an IMG.
I have tested this on Linux with Firefox 119.0.1 and Chromium 119.0.6045.159.
--Jeff Carter"Now go away or I shall taunt you a second time."Monty Python and 
the Holy Gral
with Gnoga.Application.Singleton;
with Gnoga.Gui.Element.Canvas.Context_2D;
with Gnoga.Gui.Element.Common;
with Gnoga.Gui.View;
with Gnoga.Gui.Window;

procedure Draw_Image_Error is
   Window  : Gnoga.Gui.Window.Window_Type;
   View    : Gnoga.Gui.View.View_Type;
   Image   : Gnoga.Gui.Element.Common.IMG_Type;
   Canvas  : Gnoga.Gui.Element.Canvas.Canvas_Type;
   Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
begin -- Draw_Image_Error
   Gnoga.Application.Title (Name => "Demonstrate error in Draw_Image");
   Gnoga.Application.HTML_On_Close (HTML => "Draw_Image_Error ended.");
   Gnoga.Application.Open_URL;
   Gnoga.Application.Singleton.Initialize (Main_Window => Window);
   View.Create (Parent => Window);
   View.Text_Alignment (Value => Gnoga.Gui.Element.Center);
   Image.Create (Parent => View, URL_Source => "rgb.jpg");
   View.New_Line;

   delay 0.5;

   Canvas.Create (Parent => View, Width => 1, Height => 1);
   --  Canvas.Create (Parent => View, Width => 500, Height => 500);
   --  Canvas.Create (Parent => View, Width => Image.Width, Height => Image.Height);

   delay 0.5;

   Canvas.Width (Value => Image.Width);
   Canvas.Height (Value => Image.Height);
   Context.Get_Drawing_Context_2D (Canvas => Canvas);
   Context.Draw_Image (Image => Image, X => 0, Y => 0);
   --  Context.Draw_Image (Image => Image, X => 0, Y => 0, Width => Image.Width, Height => Image.Height);

   delay 9.0;

   Gnoga.Application.Singleton.End_Application;
end Draw_Image_Error;

Attachment: draw_image_error.gpr
Description: Binary data

_______________________________________________
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list

Reply via email to