Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Czechleba  
#1 Posted : Thursday, January 29, 2004 4:49:00 PM(UTC)
Czechleba

Rank: Member

Groups: Member
Joined: 1/29/2004(UTC)
Posts: 1

I have a problem to read out the bacakground color from gif-pictures in ASP.

I want to do that automatic to set this color transparent.

I tried to set a object "Set objBitmap2 = Server.CreateObject("GraphicsMillMultiImage.GifReader.2.0")" but I always get a error.

Can someone help me.

I need the code .

Thank you for your answer

Soory my english is so bad . I am from Germany :)

Andrew  
#2 Posted : Thursday, January 29, 2004 10:39:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
ProgID for GifReader is GraphicsMill.GifReader. So try

Code:
Set objGifReader = Server.CreateObject("GraphicsMill.GifReader")

But it is possible you need not GifReader at all. I have sent you a message with a code sample which uses Bitmap object only.

Edited by user Thursday, December 20, 2007 6:53:54 PM(UTC)  | Reason: Not specified

Andrew  
#3 Posted : Thursday, January 29, 2004 10:44:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
The idea is to consider that top-left corner always contain background color (or some other point). It is true for wide class of GIF files (like logos, buttons, etc). In this case you can use this code:

Code:
<%
Dim objBitmap
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
objBitmap.IsLzwEnabled = True
objBitmap.LoadFromFile Server.MapPath("someimage.gif")
objBitmap.ColorTreatment = 3 ' it is necessary to 
                                             ' specify that Pixels 
                                             ' property should return index in palette 
                                             ' instead of RGB color 

Dim intBackgroundIndex
intBackgroundIndex = objBitmap.Data.Pixels(0,0) ' top left corner

objBitmap.Data.Palette.SetTransparentIndex intBackgroundIndex

objBitmap.Formats.GifIsTransparent = True
objBitmap.SaveToStream Response
%>

Edited by user Thursday, December 20, 2007 6:54:04 PM(UTC)  | Reason: Not specified

Andrew  
#4 Posted : Thursday, January 29, 2004 10:53:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
But if you need to read BackgroundIndex property from GIF file, you should use GifReader object. However note, that it can mean not exactly what you expect. First of all, this property makes sense not for all GIF files, but only for those which have a global palette. Besides, this property not always used to fill a background. It is intended for animated GIF files (to render animation properly). If you work with common non-animated GIF, a software used to create this file may disregard initialization of this value.

So the method used above should be more reliable. But anyway you can test both methods yourself and decide which works better for the class of images you process.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.