Re: [NTLK] [ANN] Screen Shooter

From: Paul Guyot (pguyot_at_kallisys.net)
Date: Wed May 29 2002 - 02:08:03 EDT


From: "victor_at_newtontalk.net" <victor_at_newtontalk.net>
Date: Tue, 28 May 2002 13:39:36 -0400

>No - that one's only greyscale. Pauls' GIF Server is 16 greys. Bug him about
>it.

Another option is Yos's GIF module for SimpleMail.

About NPDS GIF Server, use is pretty straightforward. Here is
something that works with both NPDS 2.x and 3.x.

Technically, there is a single method which you access at
GetRoot().|GIF Server:Kallisys|.GIFLib:BitmapToGIF( bitmap,
colorTable, interlace ) or GetRoot().|pGIF
Server:Kallisys|.GIFLib:BitmapToGIF( bitmap, colorTable, interlace )
depending on the version.

Bitmap is a NewtonOS bitmap made with MakeBitmap.
ColorTable is a frame with the following slots:
- transparent: the transparent color index (default is no transparency)
- background: the background color index (default is 0)
- colors: an array with the colors. Each color is an integer built
with PackRGB.

Example:
Take a view and build a GIF out of it. Uses the internal store for
temporary storage of the bitmap.

DefConst( 'kGIFServerNPDS3Sym, '|GIF Server:Kallisys| );
DefConst( 'kGIFServerNPDS2Sym, '|pGIF Server:Kallisys| );
DefConst( 'k16Colors, [
        PackRGB( 0xFFFF, 0xFFFF, 0xFFFF ),
        PackRGB( 0xEEEE, 0xEEEE, 0xEEEE ),
        PackRGB( 0xDDDD, 0xDDDD, 0xDDDD ),
        PackRGB( 0xCCCC, 0xCCCC, 0xCCCC ),
        PackRGB( 0xBBBB, 0xBBBB, 0xBBBB ),
        PackRGB( 0xAAAA, 0xAAAA, 0xAAAA ),
        PackRGB( 0x9999, 0x9999, 0x9999 ),
        PackRGB( 0x8888, 0x8888, 0x8888 ),
        PackRGB( 0x7777, 0x7777, 0x7777 ),
        PackRGB( 0x6666, 0x6666, 0x6666 ),
        PackRGB( 0x5555, 0x5555, 0x5555 ),
        PackRGB( 0x4444, 0x4444, 0x4444 ),
        PackRGB( 0x3333, 0x3333, 0x3333 ),
        PackRGB( 0x2222, 0x2222, 0x2222 ),
        PackRGB( 0x1111, 0x1111, 0x1111 ),
        PackRGB( 0x0000, 0x0000, 0x0000 )
        ] );
DefConst( 'kBWColors, [
        PackRGB( 0xFFFF, 0xFFFF, 0xFFFF ),
        PackRGB( 0x0000, 0x0000, 0x0000 )
        ] );

...

func ( inView )
begin
   local theGIFServer := GetRoot().(kGIFServerNPDS3Sym); // Try 3.x first
   if (theGIFServer = nil) then // Not present, try 2.x
   theGIFServer := GetRoot().(kGIFServerNPDS2Sym);
   if (theGIFServer) then
   begin
     // Check the depth of the screen.
     local boolean IHave4Bits := NIL;
     if HasSlot(Gestalt(kGestalt_SystemInfo), 'screendepth) and
       Gestalt(kGestalt_SystemInfo).screendepth >= 4 then
       IHave4Bits := true;
     local array{ colors := kBWColors;
     local options := {
       depth: 1, // Default is B&W
       store: GetStores()[0] // Use internal store for temporary storage.
     };
     if (IHave4Bits) then
     begin
       colors := k16Colors;
       options.depth := 4;
     end;

     // Create the bitmap.
     local frame theBounds := inView.viewBounds;
     local int width := theBounds.right - theBounds.left;
     local int height := theBounds.top - theBounds.bottom;
     local theBitmap := MakeBitmap( width, height, options );

     // Clip the view into the bitmap.
     inView:ViewIntoBitmap( nil, nil, theBitmap );

     return
       theGIFServer.GIFLib:BitmapToGIF(
           theBitmap,
          { colors: colors }, // Color table.
          nil /* interlace */ );
   end else begin
     // Complain to the user.
   end;
end;

HTH,

Paul

-- 
Home page: http://www.kallisys.com/
Newton-powered WebServer: http://newton.kallisys.net:8080/

-- Read the List FAQ/Etiquette: http://www.newtontalk.net/faq.html Read the Newton FAQ: http://www.guns-media.com/mirrors/newton/faq/ This is the NewtonTalk mailing list - http://www.newtontalk.net



This archive was generated by hypermail 2.1.2 : Wed Jun 12 2002 - 20:02:52 EDT