	load	'macros.dump'
	include 'driver.equ'
	include 'scrap.equ'
	include 'dbsc.equ'

	IMPORT	D_NeedHand
	import	X_ClipData

X_ScDBtoPICT	PROC	EXPORT
	;Using X_DBScrapData

	input Src:l

	local Sptr:l,Dptr:l,Dsize:l,Offset:l

	output Dest:l

	error err

	begin

	MoveLong [Src],Sptr
	lda [Sptr]
	cmp #X_DBCellType
	jne notvalid

	ldy #X_DBRows
	lda [Sptr],y
	cmp #1
	jne notvalid

	ldy #X_DBColumns
	lda [Sptr],y
	cmp #1
	jne notvalid

	Addwl #X_DBScHeaderSize,Sptr

	ldy #X_DBFType
	lda [Sptr],y
	cmp #X_DBPict
	jne notvalid

	MoveLong [Sptr],Offset
	AddLong Sptr,Offset,Sptr
	lda [Sptr]
	jne notvalid

	Addwl #2,Sptr

	MoveLong [Sptr],Dsize

	SpaceLong
	PushLong Dsize
	jsl D_NeedHand
	sta err
	PullLong Dest
	jcs exit

	MoveLong [Src],Sptr
	Addwl #X_DBScHeaderSize,Sptr
	AddLong Sptr,Offset,Sptr
	Addwl #2,Sptr

	Addwls #4,Sptr
	PushLong [Dest]
	PushLong Dsize
	_BlockMove

	bra exit

notvalid	MoveWord #-1,err
	bra exit

exit	return
	ENDP
	END

