[futurebasic] Re: [FB] Folder exists

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

From: Robert Covington <artlythere@...>
Date: Wed, 21 May 2003 17:45:26 -0400
On Wednesday, May 21, 2003, at 05:27  PM, Alain Pastor wrote:

>
>
> Craig Hoyt wrote:
>> Michael, thank you for the reply to my question. I've been away from 
>> my
>> computer for several days and haven't had a chance to test your 
>> routine. It
>> looks like what I need.
>> As long as I'm sending this... I have another question for the List. 
>> I need
>> to save an image as a JPEG file. I've looked around to see what FB 
>> has to
>> offer and also in the QT toolbox routines but can't find a match for 
>> my
>> situation. The image is in memory (a PICT handle) and I need to save 
>> it
>> without user intervention (no SaveAs dialog). Does anybody know how 
>> to do
>> this?
>
> Craig,
>
> Why don't you save your PICT in a file first and use USR 
> ConvertImageFile right after?
>
> Alain

That's easy enough, but not as flexible as the below (if this works, I 
adapted it from my GWorld sourced same)

You will need :

GraphicsExportSetInputPicture (GraphicsExportComponent  ci, handle Pict 
) = ComponentResult

...and any others that flag as errors. I have them, email.

Global used is  gHasQT4 , a flag for the version being ok

// Begin FB3 Thingie

_codecMinQuality                   = &00000000
_codecLowQuality                   = &00000100
_codecNormalQuality                = &00000200
_codecHighQuality                  = &00000300
_codecMaxQuality                   = &000003FF
_codecLosslessQuality              = &00000400


local FN SavePICTasJPEGFiIe( PictH as handle, fileSpec as ptr to 
FSSpec,¬
  format as OSType,theDepth,xDpi,yDpi,  fCrtr as OSType)
dim @ge as GraphicsExportComponent
dim err  as ComponentResult
DIM fCrtr as OSType

err = fn OpenADefaultComponent( _"grex",_"JPEG", @ge )
If err Then Goto "BailJPEG"

err = fn GraphicsExportSetInputPicture( ge, PictH )
If err Then Goto "BailJPEG"

err = fn GraphicsExportSetDepth(ge,theDepth )
If err Then Goto "BailJPEG"

err = fn GraphicsExportSetOutputFile( ge, #fileSpec )
If err Then Goto "BailJPEG"

Long if gHasQT4 // Only available that version or higher

// Set resolution
err = FN GraphicsExportSetResolution (ge,FN LONG2FIX(xDpi),FN 
LONG2FIX(yDpi) )
If err Then Goto "BailJPEG"

// Set compression quality
err = FN GraphicsExportSetCompressionQuality(ge,_codecNormalQuality)// 
Other constant here.
If err Then Goto "BailJPEG"

// Set creator with the below
err = FN GraphicsExportSetOutputFileTypeAndCreator ( ge,format,fCrtr)
If err Then Goto "BailJPEG"

End If

err = fn GraphicsExportDoExport( ge, #_nil )

"BailJPEG"

err = fn CloseComponent (ge)

end fn = err

// CALL WITH your FSSpec and PictHandle and hRes  and vRes (72 or 
whatever)
err = fn SavePICTasJPEGFiIe(PictH,SaveFSSpec,¬
  _"JPEG",32,hRes,vRes, _"GKON")