Files
harbour-core/harbour/contrib/hbfimage/tests/fitest.prg
Viktor Szakats f6c08520e4 2012-07-21 18:31 UTC+0200 Viktor Szakats (vszakats syenar.net)
+ tests/stripeol.hb
    + added script to strip spaces at EOL

  * contrib/gtalleg/tests/test.prg
  * contrib/gtwvg/tests/demoxbp.prg
  * contrib/gtwvg/tests/wvgactivex.prg
  * contrib/gtwvg/tests/wvgxbp.prg
  * contrib/gtwvg/wvgclass.prg
  * contrib/hbamf/tests/tstendin.prg
  * contrib/hbbz2/tests/test.prg
  * contrib/hbcairo/tests/fancytxt.prg
  * contrib/hbcairo/tests/table.prg
  * contrib/hbct/ctrand.prg
  * contrib/hbct/doc/en/addascii.txt
  * contrib/hbct/doc/en/atadjust.txt
  * contrib/hbct/doc/en/count.txt
  * contrib/hbct/doc/en/ct.txt
  * contrib/hbct/doc/en/ctc.txt
  * contrib/hbct/doc/en/ctmath.txt
  * contrib/hbct/doc/en/ctmath2.txt
  * contrib/hbct/doc/en/ctpad.txt
  * contrib/hbct/doc/en/ctstr.txt
  * contrib/hbct/doc/en/datetime.txt
  * contrib/hbct/doc/en/dattime2.txt
  * contrib/hbct/doc/en/exponent.txt
  * contrib/hbct/doc/en/finan.txt
  * contrib/hbct/doc/en/ftoc.txt
  * contrib/hbct/doc/en/justify.txt
  * contrib/hbct/doc/en/keyset.txt
  * contrib/hbct/doc/en/misc1.txt
  * contrib/hbct/doc/en/num1.txt
  * contrib/hbct/doc/en/numat.txt
  * contrib/hbct/doc/en/numconv.txt
  * contrib/hbct/doc/en/pos1.txt
  * contrib/hbct/doc/en/pos2.txt
  * contrib/hbct/doc/en/posdiff.txt
  * contrib/hbct/doc/en/print.txt
  * contrib/hbct/doc/en/range.txt
  * contrib/hbct/doc/en/relation.txt
  * contrib/hbct/doc/en/remove.txt
  * contrib/hbct/doc/en/replace.txt
  * contrib/hbct/doc/en/screen1.txt
  * contrib/hbct/doc/en/strdiff.txt
  * contrib/hbct/doc/en/strswap.txt
  * contrib/hbct/doc/en/token1.txt
  * contrib/hbct/doc/en/token2.txt
  * contrib/hbct/doc/en/trig.txt
  * contrib/hbct/doc/en/video.txt
  * contrib/hbct/doc/en/wordtoch.txt
  * contrib/hbct/getinfo.prg
  * contrib/hbfimage/tests/fitest.prg
  * contrib/hbgd/gdimage.prg
  * contrib/hbgd/tests/counter.prg
  * contrib/hbgd/tests/gdtest.prg
  * contrib/hbgd/tests/gdtestcl.prg
  * contrib/hbgd/tests/test_out.prg
  * contrib/hbide/idetags.prg
  * contrib/hblzf/tests/test2.prg
  * contrib/hbmisc/doc/en/ht_conv.txt
  * contrib/hbmisc/fcomma.prg
  * contrib/hbmisc/fileread.prg
  * contrib/hbmisc/hbedit.prg
  * contrib/hbnf/anomatch.prg
  * contrib/hbnf/calendar.prg
  * contrib/hbnf/clrsel.prg
  * contrib/hbnf/dispmsg.prg
  * contrib/hbnf/doc/en/aading.txt
  * contrib/hbnf/doc/en/aavg.txt
  * contrib/hbnf/doc/en/acctadj.txt
  * contrib/hbnf/doc/en/acctmnth.txt
  * contrib/hbnf/doc/en/acctqtr.txt
  * contrib/hbnf/doc/en/acctweek.txt
  * contrib/hbnf/doc/en/acctyear.txt
  * contrib/hbnf/doc/en/adessort.txt
  * contrib/hbnf/doc/en/aemaxlen.txt
  * contrib/hbnf/doc/en/aeminlen.txt
  * contrib/hbnf/doc/en/amedian.txt
  * contrib/hbnf/doc/en/anomatch.txt
  * contrib/hbnf/doc/en/any2any.txt
  * contrib/hbnf/doc/en/aredit.txt
  * contrib/hbnf/doc/en/asum.txt
  * contrib/hbnf/doc/en/at2.txt
  * contrib/hbnf/doc/en/bitclr.txt
  * contrib/hbnf/doc/en/bitset.txt
  * contrib/hbnf/doc/en/blink.txt
  * contrib/hbnf/doc/en/byt2bit.txt
  * contrib/hbnf/doc/en/byt2hex.txt
  * contrib/hbnf/doc/en/byteand.txt
  * contrib/hbnf/doc/en/byteneg.txt
  * contrib/hbnf/doc/en/bytenot.txt
  * contrib/hbnf/doc/en/bytexor.txt
  * contrib/hbnf/doc/en/calendar.txt
  * contrib/hbnf/doc/en/chdir.txt
  * contrib/hbnf/doc/en/cntryset.txt
  * contrib/hbnf/doc/en/color2n.txt
  * contrib/hbnf/doc/en/d2e.txt
  * contrib/hbnf/doc/en/datecnfg.txt
  * contrib/hbnf/doc/en/dayofyr.txt
  * contrib/hbnf/doc/en/daytobow.txt
  * contrib/hbnf/doc/en/dfile.txt
  * contrib/hbnf/doc/en/diskfunc.txt
  * contrib/hbnf/doc/en/dispc.txt
  * contrib/hbnf/doc/en/dispmsg.txt
  * contrib/hbnf/doc/en/dosver.txt
  * contrib/hbnf/doc/en/e2d.txt
  * contrib/hbnf/doc/en/easter.txt
  * contrib/hbnf/doc/en/elapsed.txt
  * contrib/hbnf/doc/en/findith.txt
  * contrib/hbnf/doc/en/floptst.txt
  * contrib/hbnf/doc/en/ftattr.txt
  * contrib/hbnf/doc/en/ftidle.txt
  * contrib/hbnf/doc/en/ftisprn.txt
  * contrib/hbnf/doc/en/ftround.txt
  * contrib/hbnf/doc/en/fttext.txt
  * contrib/hbnf/doc/en/gcd.txt
  * contrib/hbnf/doc/en/getenvrn.txt
  * contrib/hbnf/doc/en/hex2dec.txt
  * contrib/hbnf/doc/en/iamidle.txt
  * contrib/hbnf/doc/en/isbit.txt
  * contrib/hbnf/doc/en/isbiton.txt
  * contrib/hbnf/doc/en/isshare.txt
  * contrib/hbnf/doc/en/kspeed.txt
  * contrib/hbnf/doc/en/linked.txt
  * contrib/hbnf/doc/en/madd.txt
  * contrib/hbnf/doc/en/menutonf.txt
  * contrib/hbnf/doc/en/metaph.txt
  * contrib/hbnf/doc/en/miltime.txt
  * contrib/hbnf/doc/en/month.txt
  * contrib/hbnf/doc/en/netpv.txt
  * contrib/hbnf/doc/en/nooccur.txt
  * contrib/hbnf/doc/en/ntow.txt
  * contrib/hbnf/doc/en/nwlstat.txt
  * contrib/hbnf/doc/en/nwsem.txt
  * contrib/hbnf/doc/en/nwuid.txt
  * contrib/hbnf/doc/en/ontick.txt
  * contrib/hbnf/doc/en/origin.txt
  * contrib/hbnf/doc/en/page.txt
  * contrib/hbnf/doc/en/pchr.txt
  * contrib/hbnf/doc/en/peek.txt
  * contrib/hbnf/doc/en/pending.txt
  * contrib/hbnf/doc/en/poke.txt
  * contrib/hbnf/doc/en/popadder.txt
  * contrib/hbnf/doc/en/proper.txt
  * contrib/hbnf/doc/en/prtesc.txt
  * contrib/hbnf/doc/en/putkey.txt
  * contrib/hbnf/doc/en/qtr.txt
  * contrib/hbnf/doc/en/rand1.txt
  * contrib/hbnf/doc/en/savearr.txt
  * contrib/hbnf/doc/en/scregion.txt
  * contrib/hbnf/doc/en/setdate.txt
  * contrib/hbnf/doc/en/setkeys.txt
  * contrib/hbnf/doc/en/setlastk.txt
  * contrib/hbnf/doc/en/settime.txt
  * contrib/hbnf/doc/en/sinkey.txt
  * contrib/hbnf/doc/en/sleep.txt
  * contrib/hbnf/doc/en/sqzn.txt
  * contrib/hbnf/doc/en/sysmem.txt
  * contrib/hbnf/doc/en/tbwhile.txt
  * contrib/hbnf/doc/en/tempfile.txt
  * contrib/hbnf/doc/en/vertmenu.txt
  * contrib/hbnf/doc/en/vidcur.txt
  * contrib/hbnf/doc/en/vidmode.txt
  * contrib/hbnf/doc/en/wda.txt
  * contrib/hbnf/doc/en/week.txt
  * contrib/hbnf/doc/en/workdays.txt
  * contrib/hbnf/doc/en/woy.txt
  * contrib/hbnf/doc/en/xbox.txt
  * contrib/hbnf/doc/en/year.txt
  * contrib/hbnf/ftround.prg
  * contrib/hbnf/metaph.prg
  * contrib/hbnf/nwsem.prg
  * contrib/hbnf/nwuid.prg
  * contrib/hbnf/pending.prg
  * contrib/hbnf/popadder.prg
  * contrib/hbnf/scregion.prg
  * contrib/hbnf/tbwhile.prg
  * contrib/hbnf/workdays.prg
  * contrib/hbodbc/browodbc.prg
  * contrib/hbqt/tests/browqt.prg
  * contrib/hbqt/tests/dbfbrowserclass.prg
  * contrib/hbqt/tests/testbrow.prg
  * contrib/hbsqlit3/tests/blob.prg
  * contrib/hbsqlit3/tests/sl3_test.prg
  * contrib/hbxbp/tests/demoxbp.prg
  * contrib/hbxbp/tests/dialogqt.prg
  * contrib/hbxbp/xbpdataref.prg
  * contrib/hbxbp/xbpmenubar.prg
  * contrib/hbxbp/xbpprintdialog.prg
  * contrib/hbxbp/xbpprinter.prg
  * contrib/hbxbp/xbprtf.prg
  * contrib/hbxbp/xbpscrollbar.prg
  * contrib/xhb/cstruct.prg
  * contrib/xhb/hblog.prg
  * contrib/xhb/hterrsys.prg
  * contrib/xhb/htjlist.prg
  * contrib/xhb/sprintf.prg
  * contrib/xhb/stream.prg
  * contrib/xhb/tcgi.prg
  * contrib/xhb/tedit.prg
  * contrib/xhb/tfile.prg
  * contrib/xhb/thtm.prg
  * contrib/xhb/trpc.prg
  * contrib/xhb/trpccli.prg
  * contrib/xhb/ttable.prg
  * contrib/xhb/txml.prg
  * contrib/xhb/xcstr.prg
  * contrib/xhb/xhberr.prg
  * contrib/xhb/xhbmt.prg
  * doc/cmpopt.txt
  * doc/en/dbstrux.txt
  * examples/hbapollo/array.prg
  * examples/hbvpdf/hbvpdf.prg
  * examples/hbvpdf/hbvpdft.prg
  * examples/hbxlsxml/xlsxml_s.prg
  * examples/hbxlsxml/xlsxml_y.prg
  * examples/httpsrv/cgifunc.prg
  * examples/httpsrv/cookie.prg
  * examples/httpsrv/modules/cookie.prg
  * examples/httpsrv/modules/info.prg
  * examples/httpsrv/modules/showcounter.prg
  * examples/httpsrv/modules/tableservletdb.prg
  * examples/httpsrv/modules/testajax.prg
  * examples/httpsrv/session.prg
  * examples/httpsrv/uhttpd.prg
  * include/hbclass.ch
  * include/hbtrace.ch
  * src/debug/dbgtinp.prg
  * src/debug/debugger.prg
  * src/debug/tbrwtext.prg
  * src/rdd/usrrdd/rdds/hscdx.prg
  * src/rtl/hbi18n2.prg
  * src/rtl/valtoexp.prg
    * formatting, fixed indentation, cleanups, deleting system specific information,
      optimizing out platform dependent code, using hb_ntos()
2012-07-21 16:48:00 +00:00

269 lines
8.9 KiB
Plaintext

/*
* $Id$
*/
/*
* Copyright 2005 Francesco Saverio Giudice <info@fsgiudice.com>
*
* FreeImage API test file
*/
#include "freeimag.ch"
#include "fileio.ch"
#define IMAGES_IN ""
#define IMAGES_OUT "imgs_out/"
PROCEDURE Main()
LOCAL im, clone, rotated, rotatedEx, rescale, im2, im3
LOCAL centerX, centerY, width, height
// LOCAL bmpinfoheader
LOCAL bmpinfo
// LOCAL bkcolor
// LOCAL iccprofile
LOCAL nH, nLen, cStr
// LOCAL appo
//? "Press Alt-D + Enter to activate debug"
//AltD( .T. )
//Inkey(0)
AltD()
// Check output directory
IF !hb_DirExists( IMAGES_OUT )
#ifdef HB_COMPAT_C53
hb_DirCreate( IMAGES_OUT )
#endif
ENDIF
? "Initialise"
fi_Initialise()
//---------------------------//
? "Set Error Message:", fi_SetOutPutMessage( fi_Error() )
//? "Set Error Message:", fi_SetOutPutMessage( NIL )
? "Version :", fi_GetVersion()
? "Copyright :", fi_GetCopyrightMessage()
? "File type :", fi_GetFileType( IMAGES_IN + "sample1.jpg" )
? "Load JPEG directly from file"
im := fi_Load( FIF_JPEG, IMAGES_IN + "sample1.jpg", JPEG_DEFAULT )
? "Clone image"
clone := fi_Clone( im )
? "Pointer :", ValToPrg( im )
? "Image Type :", fi_GetImageType( im )
? "Color Used :", fi_GetColorsUsed( im )
? "Pixel size :", fi_GetBPP( im )
? "Width :", fi_GetWidth( im )
? "Height :", fi_GetHeight( im )
? "Byte Size :", fi_GetLine( im )
? "Pitch :", fi_GetPitch( im )
? "DIB Size :", fi_GetDIBSize( im )
? "Dots per Meter X :", fi_GetDotsPerMeterX( im )
? "Dots per Meter Y :", fi_GetDotsPerMeterY( im )
? "Color Type :", fi_GetColorType( im )
? "Red Mask :", fi_GetRedMask( im )
? "Green Mask :", fi_GetGreenMask( im )
? "Blue Mask :", fi_GetBlueMask( im )
? "Transp. Count :", fi_GetTransparencyCount( im )
? "Is Transparent ? :", fi_IsTransparent( im )
?
? "Save BMP ? :", fi_Save( FIF_BMP , im, IMAGES_OUT + "sample1.bmp", BMP_DEFAULT )
? "Save JPG ? :", fi_Save( FIF_JPEG, im, IMAGES_OUT + "sample1.jpg", JPEG_DEFAULT )
? "Save PNG ? :", fi_Save( FIF_PNG , im, IMAGES_OUT + "sample1.png", PNG_DEFAULT )
? "Save TIFF ? :", fi_Save( FIF_TIFF, clone, IMAGES_OUT + "sample1.tif", TIFF_DEFAULT )
? "Flip Horizontal ?:", fi_FlipHorizontal( clone )
? "Save JPG ? :", fi_Save( FIF_JPEG, clone, IMAGES_OUT + "horizont.jpg", JPEG_DEFAULT )
? "Flip Vertical ? :", fi_FlipVertical( clone )
? "Save JPG ? :", fi_Save( FIF_JPEG, clone, IMAGES_OUT + "vertical.jpg", JPEG_DEFAULT )
? "Rotate Classic :", ValToPrg( rotated := fi_RotateClassic( clone, 90 ) )
? "Save JPG ? :", fi_Save( FIF_JPEG, rotated, IMAGES_OUT + "rotate.jpg", JPEG_DEFAULT )
fi_Unload( rotated )
centerx := fi_GetWidth( clone ) / 2
centery := fi_GetHeight( clone ) / 2
? "Rotate Ex :", ValToPrg( rotatedEx := fi_RotateEx( clone, 15, 0, 0, centerx, centery, .T. ) )
? "Save JPG ? :", fi_Save( FIF_JPEG, rotatedEx, IMAGES_OUT + "rotateex.jpg", JPEG_DEFAULT )
fi_Unload( rotatedEx )
width := fi_GetWidth( im )
height := fi_GetHeight( im )
? "Rescale :", ValToPrg( rescale := fi_Rescale( im, width / 2, height / 2, FILTER_BICUBIC ) )
? "Save JPG ? :", fi_Save( FIF_JPEG, rescale, IMAGES_OUT + "rescale.jpg", JPEG_DEFAULT )
fi_Unload( rescale )
im2 := fi_Clone( im )
? "Adjust Gamma ? :", fi_AdjustGamma( im2, 3.0 )
? "Save JPG ? :", fi_Save( FIF_JPEG, im2, IMAGES_OUT + "adjgamma.jpg", JPEG_DEFAULT )
fi_Unload( im2 )
im2 := fi_Clone( im )
? "Adjust Brightness:", fi_AdjustBrightness( im2, - 30 )
? "Save JPG ? :", fi_Save( FIF_JPEG, im2, IMAGES_OUT + "adjbrigh.jpg", JPEG_DEFAULT )
fi_Unload( im2 )
im2 := fi_Clone( im )
? "Adjust Contrast ?:", fi_AdjustContrast( im2, - 30 )
? "Save JPG ? :", fi_Save( FIF_JPEG, im2, IMAGES_OUT + "adjcontr.jpg", JPEG_DEFAULT )
fi_Unload( im2 )
im2 := fi_Clone( im )
? "Invert ? :", fi_Invert( im2 )
? "Save JPG ? :", fi_Save( FIF_JPEG, im2, IMAGES_OUT + "invert.jpg", JPEG_DEFAULT )
fi_Unload( im2 )
? "Red Channel :", ValToPrg( im2 := fi_GetChannel( im, FICC_RED ) )
? "Save JPG ? :", fi_Save( FIF_JPEG, im2, IMAGES_OUT + "red.jpg", JPEG_DEFAULT )
fi_Unload( im2 )
? "Green Channel :", ValToPrg( im2 := fi_GetChannel( im, FICC_GREEN ) )
? "Save JPG ? :", fi_Save( FIF_JPEG, im2, IMAGES_OUT + "green.jpg", JPEG_DEFAULT )
fi_Unload( im2 )
? "Blue Channel :", ValToPrg( im2 := fi_GetChannel( im, FICC_BLUE ) )
? "Save JPG ? :", fi_Save( FIF_JPEG, im2, IMAGES_OUT + "blue.jpg", JPEG_DEFAULT )
fi_Unload( im2 )
? "Copy :", ValToPrg( im2 := fi_Copy( im, 300, 100, 800, 200 ) )
? "Save JPG ? :", fi_Save( FIF_JPEG, im2, IMAGES_OUT + "copy.jpg", JPEG_DEFAULT )
im3 := fi_Clone( im )
? "Paste ? :", fi_Paste( im3, im2, 10, 10, 70 )
? "Save JPG ? :", fi_Save( FIF_JPEG, im3, IMAGES_OUT + "paste.jpg", JPEG_DEFAULT )
fi_Unload( im2 )
fi_Unload( im3 )
? "Allocate Bitmap :", ValToPrg( im3 := fi_AllocateT( FIT_BITMAP, 320, 200, 32 ) )
? "Save JPG ? :", fi_Save( FIF_JPEG, im3, IMAGES_OUT + "allocate.jpg", JPEG_DEFAULT )
fi_Unload( im3 )
? "Create ERROR :"
? "Save GIF ? :", fi_Save( FIF_GIF, im, IMAGES_OUT + "wrong.gif", 0 )
//? ValToPrg( fi_GetInfoHeader( im ) )
//bmpinfoheader:Buffer( fi_GetInfoHeader( im ), .T. )
//bmpinfoheader:Pointer( fi_GetInfoHeader( im ) )
//? "Header :", ValToPrg( bmpinfoheader )
//? bmpinfoheader:SayMembers(" ", .t., .t.)
//bmpinfo:Pointer( fi_GetInfo( im ) )
bmpinfo := NIL // To fix warning
? "Info :", ValToPrg( bmpinfo )
//? bmpinfo:SayMembers(" ", .t., .t.)
? "-----------------------------------------------------"
//? ValType( bmpinfo:Devalue() )
//Tracelog( "bmpinfoheader", ValToPrg( bmpinfoheader ), ;
// bmpinfoheader:SayMembers(, .t.), bmpinfoheader:Value(), bmpinfoheader:DeValue(), hb_dumpvar( bmpinfoheader:Array() ), hb_dumpvar( bmpinfoheader:acMembers ) )
//appo := bkcolor:Value()
//? bkcolor:Pointer( fi_GetBackgroundColor( im ) )
//? fi_GetBackgroundColor( im, @bkcolor:Value() )
//bkcolor:Buffer( appo )
//? bkcolor:SayMembers(" ", .t., .t.)
//bkcolor:rgbBlue := 205
//? fi_SetBackgroundColor( im, hb_String2Pointer( bkcolor:Value() ) )
Tracelog( "linha 168" )
//? fi_SetBackgroundColor( im, bkcolor:Value() )
Tracelog( "linha 170" )
//? bkcolor:SayMembers(" ", .t., .t.)
Tracelog( "linha 162" )
//? bkcolor:Pointer( fi_GetBackgroundColor( im ) )
//? fi_GetBackgroundColor( im, @bkcolor:Value() )
//bkcolor:Buffer( appo )
Tracelog( "linha 176" )
//? bkcolor:SayMembers(" ", .t., .t.)
Tracelog( "linha 179" )
//iccprofile:Pointer( fi_GetICCProfile( im ) )
Tracelog( "linha 181" )
//? "Header :", ValToPrg( iccprofile )
Tracelog( "linha 183" )
//? iccprofile:SayMembers(" ", .T., .T. )
//bmpinfoheader:Reset()
//appo := NIL
//bmpinfoheader := NIL
//hb_GCAll( .T. )
? "Unload images from memory"
fi_Unload( im )
fi_Unload( clone )
//
IF ( nH := FOpen( IMAGES_IN + "sample1.jpg" ) ) != F_ERROR
nLen := FSeek( nH, 0, FS_END )
FSeek( nH, 0, FS_SET )
cStr := Space( nLen )
FRead( nH, @cStr, nLen )
FClose( nH )
? "Load JPEG from memory"
im := fi_LoadFromMem( FIF_JPEG, cStr, JPEG_DEFAULT )
? "Pointer :", ValToPrg( im )
? "Image Type :", fi_GetImageType( im )
? "Save PNG ? :", fi_Save( FIF_PNG, im, IMAGES_OUT + "sample2.png", PNG_DEFAULT )
ENDIF
//---------------------------//
? "DeInitialise"
fi_Deinitialise()
?
? "Look at " + IMAGES_OUT + " folder for output images"
?
RETURN
PROCEDURE fi_Error( cFormat, cMessage )
? "ERROR!..."
? "Format : ", cFormat
? "Message : ", cMessage
RETURN
PROCEDURE TraceLog( c )
HB_SYMBOL_UNUSED( c )
RETURN
FUNCTION ValToPrg( xValue )
LOCAL cType := ValType( xValue )
DO CASE
CASE cType == "C"
xValue := StrTran( xValue, Chr( 0 ), '" + Chr( 0 ) + "' )
xValue := StrTran( xValue, Chr( 9 ), '" + Chr( 9 ) + "' )
xValue := StrTran( xValue, Chr( 10 ), '" + Chr( 10 ) + "' )
xValue := StrTran( xValue, Chr( 13 ), '" + Chr( 13 ) + "' )
xValue := StrTran( xValue, Chr( 26 ), '" + Chr( 26 ) + "' )
RETURN '"' + xValue + '"'
CASE cType == "N" ; RETURN hb_ntos( xValue )
CASE cType == "D" ; RETURN 'HB_SToD("' + DToS( xValue ) + '")'
CASE cType == "L" ; RETURN iif( xValue, ".T.", ".F." )
CASE cType == "O" ; RETURN xValue:className() + " Object"
CASE cType == "U" ; RETURN "NIL"
CASE cType == "B" ; RETURN '{||...}'
CASE cType == "A" ; RETURN '{.[' + hb_ntos( Len( xValue ) ) + '].}'
CASE cType == "M" ; RETURN 'M:"' + xValue + '"'
ENDCASE
RETURN ""