Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create GIF file in ASP? 1

Status
Not open for further replies.

irate

Programmer
Jan 29, 2001
92
0
0
GB
I would like to know if it is possible to create a GIF image using the filesystem object in ASP in a similar way to creating a text file.

I know you can create other files using custom objects, such as PDFs but I was thinking that if I knew the format of a GIF image and had the raw data then I could write the file and convert it to hex then save it, thus creating the image.
Obviously I don’t know the GIF file format though so any other suggestions would be great.

In case you are wondering, I currently have a page in ASP with a palette and canvas, you can click on the colours in the palette and then click on the canvas to turn the ‘pixels’ that colour, the pixels are just table cells that change the bgcolor.
It is just a sort of fun little drawing page I wrote, but I think it would be really cool if I could take the thing that is drawn in the table and save it as a real image.
 
It is possible, yes, but not nearly as fun as you would think writing one from scratch. I did one that handled black and white BMP images at one point and even it wasn't to much fun. I looked around and most people will create COM or Java objects to save the information. This takes a lot of the hard work out of it since a) they already have that capability and b) even if you did want to write the raw data with one of them they actually have real Byte manipulation capabilities (unlike ASP which has, well, nothing).
Here's a link to a guy manipulating just the color header of a gif image in ASP:
-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Hi Tarwin, thanks for that link.
It was sort of useful, but at the same time, not at all.
I have a link here: to the GIF file format I found, and currently I have my page setup so that after the user submits the form it creates an array every pixel in the drawing with its colour.
I also have variables for the image width, height, number of colours and colours in the palette.
Using this I know I can construct a string of hex numbers that could be saved as a GIF file. The trouble is I don’t really under stand the file format or how I can save that hex string as a file. (In the code form the link you gave the guy only prints an image to screen using binary.write)
Any other help you can give would be very much appreciated, especially if you know of a good detailed explanation of how the gif file format works.
If necessary I can post up my ASP so far.
Thanks again.
PS. Don't worry, I didn’t expect it to be fun, ;0)
 
The problem I had when I was doing bmp's is exactly where you are right now, writing to the file. I had numerous problems getting the data from integers in my array to bytes in a binary file. The two options you have for writing are using the ADO Stream objects Write method or use the FileSystemObject to open the file with a textstream and convert your data to ASCII or Unicode before writing it.

It's been at least 7 or 8 months since I did this and unfortunatly I can't find the files I made or I would have some examples for you.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Ah ha, knew there was another post in here somewhere that was playnig with image data. This code is only examining the data but might be helpful with the data manipulation:
thread333-489647

I thought there was also a conversion/resize thread with code but I can't seem to find it.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Thanks again for that, i will post up some urls of work if i ever get anywhere with this...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top