gd library - help
gd library - help
In the examples, there is an example to use the gd library "gd_test.bas". It creates a file called test.gif. This library is pretty awesome and I would like to use it as a basis for many programs like picture viewer and to convert my, sf.phpcad.net, to a much better desktop application. probably textcad. In the example there is this line.
declare function saveImgToGIF( byval img as gdImagePtr, filename as string ) as integer
Is there anyway to display this image on a freebasic screen?
Thanks, Bill
declare function saveImgToGIF( byval img as gdImagePtr, filename as string ) as integer
Is there anyway to display this image on a freebasic screen?
Thanks, Bill
hey, I never used this lib before, and i don't have the lib (can't find -lgd on compile), but I made some guesses as to how the lib handles things internally. Maybe this works, but if not then sorry. It's only a guess.
Code: Select all
#Include "gd\gd.bi"
#Include "crt.bi"
Dim As gdImagePtr myGIF
Dim As FILE Ptr GIF_File
Sub GIF_Blit( giffy As gdImagePtr, x As Integer, y As Integer )
Dim As Integer calc
calc = giffy->sy * giffy->sx
calc += 4
Dim As uByte img( calc - 1 )
Cast( uShort Ptr, Varptr( img( 0 ) ) )[0] = giffy->sx Shl 3
Cast( uShort Ptr, Varptr( img( 0 ) ) )[1] = giffy->sy
For calc = 0 To giffy->sy - 1
MemSet( Varptr( Cast( uShort Ptr, Varptr( img( 0 ) ) )[2] ) + ( calc * giffy->sx ), giffy->pixels[calc], giffy->sx )
Next
Put( x, y ), img
End Sub
screen 13
GIF_File = fopen( "anemone.gif", "r" )
myGIF = gdImageCreateFromGif( GIF_File )
GIF_Blit( myGIF )
Sleep
gdImageDestroy( myGIF )
thanks
libgd2-xpm-dev - GD Graphics Library version 2 (development version)
You should try a debian based system. I use hard disk install of kanotix and love it.
apt-get install libgd2-xpm-dev and you are done.
I will give your idea a go.
You should try a debian based system. I use hard disk install of kanotix and love it.
apt-get install libgd2-xpm-dev and you are done.
I will give your idea a go.
didn't work
I could not get it to work, kept getting segmentation fault. But, did get a verticle line of dots one time
-
- Posts: 8579
- Joined: May 28, 2005 3:28
- Contact:
I think you can could get it to work
I think you could get it to work if you had a library for it. The png works, but somehow the WBMP does not make a correct header fro a bmp file. Thus, I tryed to use pload, but could not get that to work.
declare function gdImageCreateTrueColor alias "gdImageCreateTrueColor" (byval sx as integer, byval sy as integer) as gdImagePtr
that is in Frebasic/inc/gd.bi
Maybe, the you dont need to compile and can use the one from php for windows.
How to Obtain the php_gd2.dll
The GD dll's are provided in the latest download packages of the PHP installation for windows.
Download the zip package for Windows from the following page:-
http://www.php.net/downloads.php
Unzip the package and copy the php_gd2.dll from the ./ext/ dir to the /ext/ dir of your installation.
( In some cases it is also necessary to place a copy of all the DLL's in the ./ext/ dir in the ./system32 dir. )
If you download the Windows binaries from php . net the gd . dll is included with it . http : / / www . php . net / do_download . php ? download_file = php ...
declare function gdImageCreateTrueColor alias "gdImageCreateTrueColor" (byval sx as integer, byval sy as integer) as gdImagePtr
that is in Frebasic/inc/gd.bi
Maybe, the you dont need to compile and can use the one from php for windows.
How to Obtain the php_gd2.dll
The GD dll's are provided in the latest download packages of the PHP installation for windows.
Download the zip package for Windows from the following page:-
http://www.php.net/downloads.php
Unzip the package and copy the php_gd2.dll from the ./ext/ dir to the /ext/ dir of your installation.
( In some cases it is also necessary to place a copy of all the DLL's in the ./ext/ dir in the ./system32 dir. )
If you download the Windows binaries from php . net the gd . dll is included with it . http : / / www . php . net / do_download . php ? download_file = php ...
Found dll
http://www.boutell.com/gd/
This is the site of the library. Although freeimage, imagemagick are good, i think this one might be the best.
This is the site of the library. Although freeimage, imagemagick are good, i think this one might be the best.
Re: gd library - help
I realize this is AGES old, but the answer to the question about if you can display a GD image - it answer is - Yes. You can do it.
Really simply, GD has a way to get the width and height of an image (imageX and imageY I think).
So you get the width and height and then clear your Freebasic buffer and then just do a FOR statement. Using GD, you just get the pixel at the X,Y location and then put it into your FreeBasic buffer. That will transfer the image to FreeBasic.
You might want to look at FLTK also. I think FLTK means Fast, Light, Tool Kit. FLTK will read graphics and do a lot of other things.
So there you have it - two answers in one post and my head hasn't exploded yet.
Really simply, GD has a way to get the width and height of an image (imageX and imageY I think).
So you get the width and height and then clear your Freebasic buffer and then just do a FOR statement. Using GD, you just get the pixel at the X,Y location and then put it into your FreeBasic buffer. That will transfer the image to FreeBasic.
You might want to look at FLTK also. I think FLTK means Fast, Light, Tool Kit. FLTK will read graphics and do a lot of other things.
So there you have it - two answers in one post and my head hasn't exploded yet.
