Re: [Gnoga-list] Errors in Gnoga.Gui.Element.Canvas.Context_2d

2023-11-18 Thread J Carter via Gnoga-list
> I've upgraded Simple Components in dev_1.8 branch: 
> https://sourceforge.net/p/gnoga/code/ci/dev_1.8/tree/
> I've tested ok with GNAT FSF 13.2 from Alire.
That compiles. Attached is a reproducer, data_error.adb, and corresponding 
project file (edit the path to gnoga.gpr as needed).
The Log call outputs
2023-11-18 21:03:10.59 :  4 3
(timestamp will vary), showing that the first dimension of a Pixel_Data_Type is 
X/columns, and the 2nd is Y/rows, since the image is 4 wide and 3 high.
The resulting PPM file contains
P3 4 3 255 255 0 0 255 0 0 0 128 0 0 0 255 255 0 0 0 128 0 0 128 0 0 0 255 255 
0 0 0 128 0 0 0 255 0 0 255
which is not what was drawn in the image.
--Jeff Carter"Now go away or I shall taunt you a second time."Monty Python and 
the Holy Gral 

On Saturday, November 18, 2023 at 10:04:14 AM GMT+1, Blady 
 wrote:  
 
 
> Le 17 nov. 2023 à 15:03, J Carter  a écrit :
> 
> > But maybe the two same errors in both code cancel each other out.
> 
> Yes, they would.
> 
> > Could you please give a reproducer?
> 
> Maybe not. I realized I hadn't pulled for a while, so I did a pull and now 
> "make all" has errors with the Simple Components. The first I saw was fixed 
> long ago, before GNAT 13 was released, IIRC: In 
> deps/simple_components/atomic-access/ada/gnat-sockets-server.adb, procedure 
> Do_Connect, 'Unchecked_Access needs to be changed to 'Unrestricted_Access. If 
> I fix that, then there are other errors that are not so obvious. It's as if 
> it's a much earlier version of the Simple Components. But that is another 
> issue.

I've upgraded Simple Components in dev_1.8 branch: 
https://sourceforge.net/p/gnoga/code/ci/dev_1.8/tree/
I've tested ok with GNAT FSF 13.2 from Alire.

Pascal.
https://blady.pagesperso-orange.fr


  with Ada.Text_IO;
with Gnoga.Application.Singleton;
with Gnoga.Gui.Element.Canvas.Context_2D;
with Gnoga.Gui.View;
with Gnoga.Gui.Window;
with Gnoga.Types.Colors;

procedure Data_Error is
   procedure Write_P3 (File_Name : in String; Image : in Gnoga.Types.Pixel_Data_Type) with
  Pre => Image'First (1) = 1 and Image'First (2) = 1;

   procedure Write_P3 (File_Name : in String; Image : in Gnoga.Types.Pixel_Data_Type) is
  Output : Ada.Text_IO.File_Type;
   begin -- Write_P3
  Ada.Text_IO.Create (File => Output, Name => File_Name);
  Ada.Text_IO.Put_Line (File => Output, Item => "P3");
  Ada.Text_IO.Put_Line
 (File => Output, Item => Integer'Image (Image'Length (1) ) & Integer'Image (Image'Length (2) ) & " 255");

  All_Rows : for Y in Image'Range (2) loop
 All_Columns : for X in Image'Range (1) loop
Ada.Text_IO.Put
   (File => Output, Item => Image (X, Y).Red'Image & Image (X, Y).Green'Image & Image (X, Y).Blue'Image);
 end loop All_Columns;

 Ada.Text_IO.New_Line (File => Output);
  end loop All_Rows;

  Ada.Text_IO.Close (File => Output);
   end Write_P3;

   Width  : constant := 4;
   Height : constant := 3;

   Window  : Gnoga.Gui.Window.Window_Type;
   View: Gnoga.Gui.View.View_Type;
   Canvas  : Gnoga.Gui.Element.Canvas.Canvas_Type;
   Context : Gnoga.Gui.Element.Canvas.Context_2D.Context_2D_Type;
   Image   : Gnoga.Gui.Element.Canvas.Context_2D.Image_Data_Type;
begin -- Data_Error
   Gnoga.Application.Title (Name => "Demonstrate error in Data");
   Gnoga.Application.HTML_On_Close (HTML => "Data_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);
   Canvas.Create (Parent => View, Width => Width, Height => Height);
   Context.Get_Drawing_Context_2D (Canvas => Canvas);

   Red : for X in 0 .. Width - 1 loop
  Context.Pixel (X => X, Y => 0, Color => Gnoga.Types.Colors.Red);
   end loop Red;

   Green : for X in 0 .. Width - 1 loop
  Context.Pixel (X => X, Y => 1, Color => Gnoga.Types.Colors.Green);
   end loop Green;

   Blue : for X in 0 .. Width - 1 loop
  Context.Pixel (X => X, Y => 2, Color => Gnoga.Types.Colors.Blue);
   end loop Blue;

   delay 0.5;

   Context.Get_Image_Data (Image_Data => Image, Left => 0, Top => 0, Width => 4, Height => 3);

   Get_Data : declare
  Pixel : constant Gnoga.Types.Pixel_Data_Type := Image.Data;
   begin -- Get_Data
  Gnoga.Log (Message => Integer'Image (Pixel'Length (1) ) & Integer'Image (Pixel'Length (2) ) );
  Write_P3 (File_Name => "data_error.ppm", Image => Pixel);
   end Get_Data;

   delay 4.5;

   Gnoga.Application.Singleton.End_Application;
end Data_Error;


data_error.gpr
Description: Binary data
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Errors in Gnoga.Gui.Element.Canvas.Context_2d

2023-11-18 Thread Blady via Gnoga-list

> Le 17 nov. 2023 à 15:03, J Carter  a écrit :
> 
> > But maybe the two same errors in both code cancel each other out.
> 
> Yes, they would.
> 
> > Could you please give a reproducer?
> 
> Maybe not. I realized I hadn't pulled for a while, so I did a pull and now 
> "make all" has errors with the Simple Components. The first I saw was fixed 
> long ago, before GNAT 13 was released, IIRC: In 
> deps/simple_components/atomic-access/ada/gnat-sockets-server.adb, procedure 
> Do_Connect, 'Unchecked_Access needs to be changed to 'Unrestricted_Access. If 
> I fix that, then there are other errors that are not so obvious. It's as if 
> it's a much earlier version of the Simple Components. But that is another 
> issue.

I've upgraded Simple Components in dev_1.8 branch: 
https://sourceforge.net/p/gnoga/code/ci/dev_1.8/tree/
I've tested ok with GNAT FSF 13.2 from Alire.

Pascal.
https://blady.pagesperso-orange.fr




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