/* AmigaE MorphOS Reggae example ghh 2023 */
/* scale picture scale.filter */
OPT MORPHOS, PREPROCESS
MODULE 'dos/dos','dos/rdargs','intuition/classes','amigaLib/boopsi' /* doMethodA() */
MODULE 'multimedia','classes/multimedia/multimedia','classes/multimedia/video'
MODULE 'exec/libraries'
ENUM ERR_NONE,ERR_MMCL,ERR_MMSF,ERR_MMFO
DEF scalefilterbase:PTR TO lib
DEF fileoutputbase:PTR TO lib
PROC scalefilterFunc()
DEF streamobj:PTR TO object,scaleobj:PTR TO object,
codecobj:PTR TO object,outputobj:PTR TO object
DEF outname[16]:STRING
DEF fns[256]:STRING
DEF template
template:= 'WIDTH 160 HEIGHT 120 MODE 2' /* string pro scale.filter MUSI mit tento tvar */
/* 0 - Box 1 - Triangle 2 - Bell 3 - B-Spline */
/* 4 - Bilinear 5 - Lanczos 6 - Mitchell */
StringF(fns,'ram:pic.png') /* orig obrazek */
StringF(outname,'ram:scaled.jpg') /* vysledny obrazek */
IF streamobj:=MediaNewObjectTagList([MMA_StreamType,'file.stream', /* ma jen jeden port 0 pro output */
MMA_StreamName,fns, /* string */
MMA_Decode,1, /* ne TRUE ale 1 pozn ghh */
MMA_Recognition,MMREC_LIGHT, /* nebo MMREC_HEAVY */
MMA_MediaType,MMT_PICTURE,NIL])
IF (scaleobj:= NewObjectA(NIL,'scale.filter',[MMA_Arguments,template, NIL])) /* zmensit-zvetsit obrazek */
IF (MediaConnectTagList(scaleobj,0,streamobj,0,[NIL])) /* propojit scaleobj (port 0 - input) a streamobj (port 0 vyjimka viz vyse) */
IF (codecobj:= MediaBuildFromArgsTagList('jpeg',scaleobj,1,[NIL])) /* format vystupu a zaroven propojení se scaleobj (port 1 - output) */
IF (outputobj:= NewObjectA(NIL,'file.output', /* zapsat na disk */
[MMA_TaskPriority,0,
MMA_StreamName, outname, NIL])) /* string */
IF (MediaConnectTagList(codecobj,1,outputobj,0,[NIL]))
doMethodA(outputobj,[MMM_SignalAtEnd,FindTask(NIL),SIGBREAKB_CTRL_C,NIL]) /* proces se da prerusit stiskem ctrl+c */
doMethodA(outputobj,[MMM_Play,NIL]) /* spusti "akci" zapis */
Wait(SIGBREAKF_CTRL_C)
ENDIF
DisposeObject(outputobj)
ENDIF
DisposeObject(codecobj)
ENDIF
ENDIF
DisposeObject(scaleobj)
ENDIF
DisposeObject(streamobj)
ELSE
WriteF('Reggae was unable to decode buffer.\n')
ENDIF
ENDPROC
PROC main() HANDLE
IF (multimediabase:= OpenLibrary('multimedia/multimedia.class',52))=NIL THEN Raise(ERR_MMCL)
IF (scalefilterbase:= OpenLibrary('multimedia/scale.filter',51))=NIL THEN Raise(ERR_MMSF)
IF (fileoutputbase:= OpenLibrary('multimedia/file.output',52))=NIL THEN Raise(ERR_MMFO)
scalefilterFunc()
EXCEPT DO
IF (multimediabase) THEN CloseLibrary(multimediabase)
IF (scalefilterbase) THEN CloseLibrary(scalefilterbase)
IF (fileoutputbase) THEN CloseLibrary(fileoutputbase)
SELECT exception /* hlaseni chyb */
CASE ERR_MMCL
WriteF('Error: Could not open multimedia.class\n')
CASE ERR_MMSF
WriteF('Error: Could not open multimedia/scale.filter\n')
CASE ERR_MMFO
WriteF('Error: Could not open multimedia/file.output\n')
ENDSELECT
ENDPROC
|