------------------------------------------------------------------------------ -- -- -- XVIEW ADA LIBRARY COMPONENTS -- -- -- -- XV_SERVER_IMAGE_PACKAGE -- -- -- -- B o d y -- -- -- -- Copyright (c) 1995 Andreas Almroth, All Rights Reserved -- -- -- -- The XVIEW ADA library is free software; you can redistribute it and/or -- -- modify it under terms of the GNU Library General Public License as -- -- published by the Free Software Foundation; either version 2, or (at your -- -- option) any later version. The XVIEW ADA library is distributed in the -- -- hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -- -- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- See the GNU Library General Public License for more details. -- -- You should have received a copy of the GNU Library General Public -- -- License along with the XVIEW ADA library; see the file COPYING.LIB. If -- -- not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, -- -- MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- Lots of bindings to XView C functions needs the Interfaces.C package. with Interfaces.C; package body Xv_Server_Image_Package is SERVER_IMAGE_BITS : constant := 1157761537; XV_WIDTH : constant := 1246234689; XV_HEIGHT : constant := 1246300289; XV_DEPTH : constant := 1249773569; ----------------------------------------------------------------------------- function Get_Server_Image (V : in Xv_Server_Image) return Server_image is begin return V.base; end Get_Server_Image; ----------------------------------------------------------------------------- procedure Finalize (V : in out Xv_Server_Image) is procedure Xv_Destroy (Object : Xv_Opaque); pragma Import (C,Xv_Destroy,"xv_destroy"); begin Xv_Destroy(Xv_Opaque(V.Base)); end Finalize; ----------------------------------------------------------------------------- procedure Initialize (V : in out Xv_Server_Image) is type M_Image_Data is array (Integer range 1..512) of Interfaces.C.Unsigned_Char; type M_Image_Data_Ptr is access all M_Image_Data; function Xv_Create (Owner : Xv_Opaque; Pkg : Xv_Pkg_Ptr; Cmd1 : Integer; Width : Integer; Cmd2 : Integer; Height : Integer; Cmd3 : Integer; Depth : Integer; Cmd4 : Integer; Data : M_Image_data; Term : Integer) return Server_Image; pragma Import (C,Xv_Create,"xv_create"); type Short_Integer is range 0..65535; -- Convert_Value converts the given value to the systems own -- presentation of values. By doing this you can use the same -- bitmap values on both BIG_ENDIAN and LITTLE_ENDIAN systems. function Convert_Value (Data : Integer) return Integer is function N_To_Hs (Data : Integer) return Integer; pragma Import (C,N_To_Hs,"ntohs"); begin return N_To_Hs(Data); end Convert_Value; function Compose_Value (Data1, Data2 : Short_Integer) return Integer is begin return Integer((Data1 * 256 + Data2)); end Compose_Value; procedure Split_Value (Data : Integer; Dataout1, Dataout2 : in out Short_Integer) is type S_Integer is range 1..255; begin Dataout1 := Short_Integer(Data) / 256; Dataout2 := Short_Integer(Data) mod 256; end Split_Value; Xv_Server_Image_Pkg : Xv_Pkg_Ptr; pragma Import (C,Xv_Server_Image_Pkg,"my_xv_server_image_pkg"); Internal_Image : aliased M_Image_Data; Image_Ptr : M_Image_Data_Ptr; I : Integer := V.The_Image'First; Data1, Data2 : Short_Integer; Data3, Data4 : Short_Integer; begin while I < V.The_Image'Last loop Data1 := Short_Integer(V.The_Image(I)); Data2 := Short_Integer(V.The_Image(I + 1)); Split_Value(Convert_Value(Compose_Value(Data1,Data2)),Data3,Data4); Internal_Image(I) := Interfaces.C.Unsigned_Char(Data3); Internal_Image(I + 1) := Interfaces.C.Unsigned_Char(Data4); I := I + 2; end loop; Image_Ptr := Internal_Image'Access; V.base := Xv_Create(0,Xv_Server_Image_Pkg,XV_WIDTH,V.Width, XV_HEIGHT,V.Height,XV_DEPTH,1, SERVER_IMAGE_BITS,Image_ptr.all,0); if V.base = 0 then raise NO_OBJECT_CREATED; end if; end Initialize; end Xv_Server_Image_Package;