/* Cam Plugin - DMS - July 2000 - by Nadège SONNET */ /* Common functions Client/Server */ /* Rev . Oct. 2000 - by Nadege SONNET */ /* Indicate a file extension */ fun extension(fi) = let 0 -> j in let 0 -> find in { while ((set find = strfind "." fi j) != nil) do set j = find + 1; substr fi j ((strlen fi) - j); };; /* Writing of a file in a bitmap (".pgn", ".jpg", ".bmp" or ".tga" format) */ fun openBMP(stringF) = let _checkpack stringF -> fP in if (fP != nil) then if (!strcmpi (extension stringF) "png") then let _LDalphaBitmap _channel fP -> alphabmp in let _GETalphaBitmapSize alphabmp -> [l h] in let _GETalphaBitmaps alphabmp -> [bmp _] in bmp else if (!strcmpi (extension stringF) "jpg") then let _LDjpeg _channel fP -> bmp in let _GETbitmapSize bmp -> [l h] in bmp else if (!strcmpi (extension stringF) "bmp") then let _LDbitmap _channel fP -> bmp in let _GETbitmapSize bmp -> [l h] in bmp else if (!strcmpi (extension stringF) "tga") then let _LDtga _channel fP -> bmp in let _GETbitmapSize bmp -> [l h] in bmp else nil else nil;; fun getTxtSize(stringF) = let _checkpack stringF -> fP in if (fP != nil) then if (!strcmpi (extension stringF) "png") then let _LDalphaBitmap _channel fP -> alphabmp in let _GETalphaBitmapSize alphabmp -> [l h] in { _DSalphaBitmap alphabmp; [l h]; } else if (!strcmpi (extension stringF) "jpg") then let _LDjpeg _channel fP -> bmp in let _GETbitmapSize bmp -> [l h] in { _DSbitmap bmp; [l h]; } else if (!strcmpi (extension stringF) "bmp") then let _LDbitmap _channel fP -> bmp in let _GETbitmapSize bmp -> [l h] in { _DSbitmap bmp; [l h]; } else if (!strcmpi (extension stringF) "tga") then let _LDtga _channel fP -> bmp in let _GETbitmapSize bmp -> [l h] in { _DSbitmap bmp; [l h]; } else nil else nil;; /* Callback used for lists */ fun strcomp(a,b) = ((strcmp a b) == 0);;