PDA

View Full Version : Dotnet: Jpg to Gif


MerlinEl
10-17-2009, 12:30 AM
Hi

1) Im try to save a Jpeg files in to Gif format
2) and after pack them to animated Gif

1) allmost done , but I cant solve why my saved gif images is so compressed.


http://img266.imageshack.us/img266/8582/mygrabfile.gif


fn convertJpegToGiff jpg_filename =
(
--create an Image dotNetClass
image_class = dotNetClass "System.Drawing.Image"
--get the saved image from file as bitmap
dotnet_bitmap = image_class.FromFile jpg_filename
--create a new GIF filename
gif_filename = (getFilenamePath jpg_filename) + (getFilenameFile jpg_filename) + ".gif"
w=dotnet_bitmap.width
h=dotnet_bitmap.height
-- left top right bottom
rect = (dotNetClass "System.Drawing.Rectangle").FromLTRB 0 0 w h
bit_24 = (dotNetClass "System.Drawing.Imaging.PixelFormat").Format24bppRgb
dotnet_bitmap_24bit = dotnet_bitmap.clone rect bit_24 --clone bitmap to 24_bit
img_format = dotNetClass "System.Drawing.Imaging.ImageFormat" -- file formats
dotnet_bitmap_24bit.save gif_filename img_format.gif --save jpg as gif
dotnet_bitmap.Dispose()
dotnet_bitmap_24bit.Dispose()
deleteFile jpg_filename
)



thanks for the help

MerlinEl
10-17-2009, 09:46 AM
or...
Is there any other way to get an animated sequence in Gif format
of these images? :shrug:

img1 = gw.getViewportDib()
img2 = gw.getViewportDib()
img3 = gw.getViewportDib()

Thanks for the reply

denisT
10-17-2009, 04:16 PM
or...
Is there any other way to get an animated sequence in Gif format
of these images? :shrug:

img1 = gw.getViewportDib()
img2 = gw.getViewportDib()
img3 = gw.getViewportDib()

Thanks for the reply

this is not so simple... check this discussion e.g.

http://bloggingabout.net/blogs/rick/archive/2005/05/10/3830.aspx

MerlinEl
10-17-2009, 09:05 PM
Yes you are right , is quite dificult :hmm: for me....

In te mean time Im searched on the internet and found some free MS Dos utilites.
The second one is better I think

gifsicle --gif sequence to anim.gif

app = "C:\tmp\gifsicle.exe "
cmd = "-d=25 C:\Temp\Grab\*.gif > E:\temp\my_grab_file.gif"
DOSCommand (app + cmd)


magickx --jpg sequence to anim.gif

app = "C:\tmp\convert.exe "
cmd = "C:\Temp\Grab\*.jpg -delay 25 E:\temp\my_grab_file.gif"
DOSCommand (app + cmd)


..anyway thank you Denis!
..maybe leater when I will be more skiled then I wil try again
to do this in DotNet ;)

denisT
10-17-2009, 09:37 PM
Yes you are right , is quite dificult :hmm: for me....

In te mean time Im searched on the internet and found some free MS Dos utilites.
The second one is better I think

gifsicle --gif sequence to anim.gif

app = "C:\tmp\gifsicle.exe "
cmd = "-d=25 C:\Temp\Grab\*.gif > E:\temp\my_grab_file.gif"
DOSCommand (app + cmd)


magickx --jpg sequence to anim.gif

app = "C:\tmp\convert.exe "
cmd = "C:\Temp\Grab\*.jpg -delay 25 E:\temp\my_grab_file.gif"
DOSCommand (app + cmd)


..anyway thank you Denis!
..maybe leater when I will be more skiled then I wil try again
to do this in DotNet ;)

it's absolutely right solution.

PS. you can use HiddenDOSCommand instead of using DOSCommand.

MerlinEl
10-17-2009, 11:35 PM
HiddenDOSCommand , nice!
thanks for this Denis :thumbsup:

CGTalk Moderation
10-17-2009, 11:35 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.