[futurebasic] Re:copybits/printing/splash

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2001 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Tue, 1 May 2001 13:26:32 -0400
>With much graciousness, Robert Covington releases his picture printing code:

>>Below is the print routine in entirety for my program Compositor,
>>edited to just the guts for your use. May it aid you in your quest.

>Robert,
>
>This is a very nice gift!
>
>Ken

Thanks, you are welcome. Please install a check for PictH after the
ClosePicture...may have gotten edited out. Nothing like printing a blank
page. :)

>p.s. Now if we can only convince you to release the splash code for
>Backup Beastie! That one is really funky.

Splattery gets you everywhere. That and $5. :) Copy the below to an
include, beware the line wrap.

Call FN doSplash(_True) for Timer OR Do/Until FN Button, typical like for a
startup situation.
Call FN doSplash(_False) for Do/Until FN Button only. For a viewing until
infinity situation.

Looks for image Resources of 130 and 131, to fit global gSplashRect, change
all to suit.
Defaults to normal drawpicture if errors with GWorld creation occur. You
can make bigger GWorlds or use more of them to add frames to the simple 2
frame animation as shown.

Wish Robert Purves would relieve me of crediting guilt for these basic
GWorld FNs, they are ubiquitous in all I write.

So, GWorld FN stuff originally by Robert Purves, until then. The below are
edited however for less demanding splashability uses.

Robert

// © 2001 Robert Covington , Animated Splash routine .
// call FN doSplash(_True) for Timer OR Do/Until FN Button
// call FN doSplash(_False) for Do/Until FN Button only.
// Image ID's are 130 and 131, choose yours to suit.
// Normal Splash randomly chooses between 2 choices of image ID.
// courtesy, Maybe. Delete to cheat your user of variety. :)

// Use freely, credit please if in a released program.
// Delays are RNDdom because original is for simulating lighting effects.
// This is best using two same images with colorized differences (hue,etc.)
// Change to suit.
// Robert Covington  < artlythere@... >


// De-Globalize to your comfort level.


Begin Globals

DIM gWinGW as long// Splash Port
DIM gWinDevice as long
DIM gSplash1 as long//Image 1 World
DIM gSplash2 as Long//Image 2 World
DIM gSplashRect as Rect //Window-image Rect
DIM gWorldsFlag as INT// Flag Var, They Be Good

End Globals

'~'3

LOCAL FN CopyGW2GW(sPort as long,dPort as long,sRect as ptr,dRect as ptr)
CALL COPYBITS(#sPort+2,#dPort+2,#sRect,#dRect,_srcCopy,0)
END FN//
'~'3
_safeExtraMem = 64*1024

LOCAL FN MakeAndLockGWorld(theRect as pointer to rect, depth)
dim qdErr
DIM @ myGWorld as long

qdErr = FN NEWGWORLD(myGWorld, depth, #theRect, 0,0,0)

LONG IF (qdErr != _noErr) OR (MEM(_maxAvail) < _safeExtraMem)
// For splash, skip error messages- will default to normal splash.
End If
long if (FN LOCKPIXELS(FN GETGWORLDPIXMAP(myGWorld)) == _false)
If myGWorld then Call disposeGWorld(myGWorld)
myGWorld = 0
end if

END FN = myGWorld

'~'3

Local FN BashWorlds
If gSplash2 then Call DisposeGWorld(gSplash2)
If gSplash1 then Call DisposeGWorld(gSplash1)
gSplash1 = 0
gSplash2 = 0
End FN

'~'
Local FN MakeSplashWorlds
gSplash1 = FN MakeAndLockGWorld(gSplashRect,32)
gSplash2 = FN MakeAndLockGWorld(gSplashRect,32)
Long if gSplash1 and gSplash2
gWorldsFlag = _True
End If
End FN
'~'

Local FN DoSplash(flag)
DIM pictHandle as handle
DIM versionStr$
DIM startTick as Long// Long Required here.

gWorldsFlag = _False

versionStr$ = "v1.0"

call setrect(gSplashRect,0,0,190,150)'Window Rect
// Adjust to Suit

Long if gFancySplash
FN MakeSplashWorlds
Long if gWorldsFlag = _True
Window -2,"",@gSplashRect,_dialogPlain// hide until ready
call getGWorld(gWinGW,gWinDevice)

pictHandle= FN GetPicture(130)//First Image
Long if pictHandle
call setGworld(gSplash1,0)
Call Drawpicture(pictHandle,gSplashRect)
Long color 60000,60000,40000
Text _geneva,9
Print %(158,105) versionStr$;
Color _zBlack
End if
pictHandle= FN GetPicture(131)// Second Image
Long if pictHandle
call setGworld(gSplash2,0)
Call Drawpicture(pictHandle,gSplashRect)
Long color 60000,60000,40000
Text _geneva,9
Print %(158,105) versionStr$;
Color _zBlack
End if

call setGworld(gWinGW,gWinDevice)
Window 2

FN CopyGW2GW(gSplash1,gWinGW,gSplashRect,gSplashRect)

delay 50

startTick = FN TickCount
Random
Long if flag
Do
delay 40 + RND(160)
FN CopyGW2GW(gSplash2,gWinGW,gSplashRect,gSplashRect)
delay 40 + RND(160)
FN CopyGW2GW(gSplash1,gWinGW,gSplashRect,gSplashRect)
Until FN Button or FN TickCount-startTick > 200 // 3+ seconds
FN BashWorlds// Done, NukeEm
Xelse
Do
delay 40 + RND(160)
FN CopyGW2GW(gSplash2,gWinGW,gSplashRect,gSplashRect)
delay 40 + RND(160)
FN CopyGW2GW(gSplash1,gWinGW,gSplashRect,gSplashRect)
Until FN Button// No TickCount this time.
FN BashWorlds// Done, NukeEm
End If
FlushEvents// click passthroughkiller
Window close #2'Get rid of splash
gWorldsFlag = _False
Xelse'Splashworld failure, use regular.
goto "ThisType"
End If
//
XELSE // Regular Splash Screen
//
"ThisType"
Window 2,"",@gSplashRect,_dialogPlain
//
DIM winID as long
if maybe then winID = 131 else winID = 130
pictHandle= FN GetPicture(winID)
Long if pictHandle
Call Drawpicture(pictHandle,gSplashRect)
Long color 60000,60000,40000
Text _geneva,9
Print %(158,105) versionStr$;
Color _zBlack
XElse
Beep
Print "Resource #131 Not Found"
End if
//
startTick = FN TickCount
//
Long if flag
Do
Until FN Button or FN TickCount-startTick > 200
Xelse
Do
Until FN Button
End If
FlushEvents
Window close #2'Get rid of splash
//
End if

END FN