Page 1 of 1

#include "gd.ch"

Posted: Thu Sep 01, 2011 5:32 am
by luisfrancisco62
Hola a todos:

alguien a utilizado las librerias bgd del hb30 en su ruta d:\hb30\contrib\hbgd\tests\

agradeceria si pudieron compilar gracias...

Re: #include "gd.ch"

Posted: Thu Sep 01, 2011 11:45 am
by Rathinagiri
Hi,

To use hbgd library you have to get GD library. This can be done from GNU Utils. Link is here.

You need to download three files, viz.,

1. Binary files ( The file libgd2.dll is required for us. )

2. Developer files ( The file libgd.dll.a is required for us. )

3. Dependencies files ( The files *.dll are required for us. )

libgd2.dll and other *.dll (freetype6.dll etc) are required at the runtime and libgd.dll.a is required at build time.

Place libgd.dll.a in harbour library path.

Include these lines in IDE configuration tab

Code: Select all

libs=gd.dll
libs=hbgd
That's all!

And I have used the following code to test and create myimage.jpg. :)

Code: Select all

#include <hmg.ch>

Function Main

   define window x at 0, 0 width 800 height 600 main
      define button gd
         row 10
         col 10
         width 80
         caption 'Ok'
         action image1()
      end button   
   
   end window
   x.center
   x.activate
Return

function image1
   local pImage
   local nColor := 0
   pImage := gdImageCreateTrueColor( 200, 200 )
   nColor := gdImageColorAllocate( pImage, 255, 255, 255 )
   gdImageFill( pImage, 10, 10, nColor )   
   nColor := gdImageColorAllocate( pImage, 0, 0, 255 )
   gdImageLine( pImage, 10, 10, 150, 150, nColor )
   gdImageJpeg( pImage, "myimage.jpg" )
   gdImageDestroy( pImage )
return nil

Re: #include "gd.ch"

Posted: Sat Sep 03, 2011 5:11 am
by luisfrancisco62
me arroja

hbmk2: Processing local make script: hbmk.hbm
Harbour 3.0.0 (Rev. 16951)
Copyright (c) 1999-2011, http://harbour-project.org/
Compiling 'COUNTER.prg'...
Lines 368, Functions/Procedures 1
Generating C source output to 'C:\Users\ADMINI~1\AppData\Local\Temp\hbmk_vpz
dir\COUNTER.c'... Done.
d:/hb30/comp/mingw/bin/../lib/gcc/mingw32/4.5.2-dw2/../../../../mingw32/bin/
xe: cannot find -lgd
d:/hb30/comp/mingw/bin/../lib/gcc/mingw32/4.5.2-dw2/../../../../mingw32/bin/
xe: cannot find -lbgd
collect2: ld returned 1 exit status
hbmk2: Error: Running linker. 1
D:\hb30\comp\mingw\bin\gcc.exe C:/Users/ADMINI~1/AppData/Local/Temp/hbmk_vpz
dir/COUNTER.o C:/Users/ADMINI~1/AppData/Local/Temp/hbmk_vpzm2t.dir/hbmk_gbbu
-mconsole -Wl,--start-group -lhbgd -lgd -lbgd -lhbct -lhbextern -lhbdebu
hbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgt
-lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -l
x -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainstd -lkernel32 -luser
lgdi32 -ladvapi32 -lws2_32 -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid
le32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre
zlib -Wl,--end-group -oCOUNTER.exe -LD:/hb30/lib/win/mingw -LD:/hb30/bin
Presione una tecla para continuar . . .


me podrias enviar un zip con un ejemplo compilado y depronto incluirlo en las proxima actualizacion de HMG

gracias muchas gracias

Re: #include "gd.ch"

Posted: Thu Sep 29, 2011 9:21 am
by fugazi
Hello Rathinagiri,

I try to put a character or a string but i cant't find a pointer to font in hmg or a hmg documentation. Can You help me?

Regards
Fugazi

Re: #include "gd.ch"

Posted: Thu Sep 29, 2011 9:44 am
by Rathinagiri
Hi,

In HMG, we don't use font pointers directly.

In GD, gdImageStringFT function is not wrapped by Harbour. Hence we have to call the 'c' level wrapper codes ourselves to write a text in JPG.

For more details please see GD documentation.

Re: #include "gd.ch"

Posted: Thu Sep 29, 2011 10:51 am
by fugazi
Hi,

I found function gdImageChar
in my PRG: gdImageChar(pImage,gdFontGetSmall(),_x1,_y1, _material, nColor)

but it is no effect. GdImageChar do not put char.

I think gdFontGetSmall() returns pointer to font only when gdfonts.h is included. I can not prepare gdfonts.h that It works with HMG. Is anybody who can help me?

Thanks
Fugazi

Re: #include "gd.ch"

Posted: Thu Sep 29, 2011 11:19 am
by Rathinagiri
Hi

Can't you compile this example?

I think you have to set the path to the windows font directory as mentioned in the example.

Code: Select all

/*
 * $Id: gdtest.prg 15849 2010-11-20 16:28:13Z vszakats $
 */

/*
 * Copyright 2004-2005 Francesco Saverio Giudice <info@fsgiudice.com>
 *
 * GD API test file
 */

#include "gd.ch"
#include "common.ch"

#define IMAGES_IN  "imgs_in" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()

PROCEDURE Main()

   LOCAL im, im2
   LOCAL black, blue, red, green, cyan
   LOCAL color, font
// LOCAL aClip

   // SET GDFONTPATH=C:\windows\fonts
   IF GetEnv( "GDFONTPATH" ) == ""
      ? "Please set GDFONTPATH"
      ? "On Windows: SET GDFONTPATH=C:\windows\fonts"
      ? "On Linux  : export GDFONTPATH=/usr/share/fonts/default/TrueType"
      ?
   ENDIF
/*
   // Check output directory
   IF !ISDirectory( IMAGES_OUT )
      DirMake( IMAGES_OUT )
   ENDIF
*/

   ? gdVersion()

   /* Create an image in memory */
   im := gdImageCreate(200, 200)

   /* Load an image in memory from file */
   im2 := gdImageCreateFromJpeg( IMAGES_IN + "conv_tst.jpg")

   /* Now work on first empty image */

   /* Allocate drawing color */
   black := gdImageColorAllocate(im, 0, 0, 0)
   blue  := gdImageColorAllocate(im, 0, 0, 255)
   red   := gdImageColorAllocate(im, 255, 0, 0)
   green := gdImageColorAllocate(im, 0, 255, 0)
   cyan  := gdImageColorAllocate(im, 0, 255, 255)

   /* Draw rectangle */
   gdImageFilledRectangle(im, 0, 0, 199, 199, cyan)
   gdImageRectangle(im, 0, 0, 199, 199, black)

   /* Draw pixel */
   gdImageSetPixel(im, 50, 5, blue)
   gdImageSetPixel(im, 50, 15, blue)

   /* Draw lines */
   gdImageLine(im, 0, 0, 199, 199, blue)
   gdImageDashedLine(im, 0, 199, 199, 0, blue)

   /* Draw polygons */
   gdImagePolygon(im, { { 10, 10 }, { 70, 10 }, { 80, 60 } }, red)
   gdImageFilledPolygon(im, { { 160, 180 }, { 170, 110 }, { 150, 160 } }, green)

   /* Draw an arc */
   gdImageArc(im, 50, 50, 40, 40, 30, 190, red )
   gdImageFilledCircle(im, 50, 150, 45, green )
   gdImageEllipse(im, 120, 120, 50, 20, blue )

   /* Draw some characters */
   font := gdFontGetLarge()

   gdImageString(im, font, 0, 0, 'Test', black)
   gdImageString(im, font, 0, 15, 'P', black)
   gdImageChar(im, font, 0, 30, 'W', black)

   gdImageStringUp(im, font, 70, 90, 'Test', black)
   gdImageStringUp(im, font, 70, 15, 'P', black)
   gdImageCharUp(im, font, 70, 30, 'W', black)

   gdImageStringFt(im, blue, "arial", 20, 30, 20, 90, 'Test')

   ? gdImageStringFTCircle(im, 120, 120, 50, 25, 0.8, "arial", 24, "Up", /*"Down"*/, red)

   /* Set Clip Rectangle */
   gdImageSetClip(im, 25, 25, 75, 75)

   /* Retrieve Clipping rectangle */
// aClip := gdImageGetClip(im)

//   ? "Clipping rectangle values"
//   ? hb_DumpVar( aClip )

   /* Query functions */
   color := gdImageGetPixel(im, gdImageSX(im) / 2, gdImageSY(im) / 2)
   ? "Pixel Color is: ", color
   ? "RGB Values: ", gdImageRed(im,color), gdImageGreen(im,color), gdImageBlue(im,color)
   ? "Alpha Value: ",  gdImageAlpha(im,color)

   /* Write Images on files */
   gdImagePng(im, IMAGES_OUT + "rect.png")

   gdImagePng(im2, IMAGES_OUT + "conv_tst.png")
   gdImageJpeg(im2, IMAGES_OUT + "conv_tst.jpg")

   /* Destroy images in memory */
   gdImageDestroy(im)
   gdImageDestroy(im2)

   ?
   ? "Look at " + IMAGES_OUT + " folder for output images"
   ?

RETURN

Re: #include "gd.ch"

Posted: Mon Oct 03, 2011 12:01 pm
by fugazi
Hi Rathinagiri

Thank You so much. I set path and now working fine. It was very important for me so thank You again.

Fugazi

Re: #include "gd.ch"

Posted: Mon Oct 03, 2011 12:08 pm
by Rathinagiri
U R Welcome. :)