loading and saving a transparent CImage

Could someone give me some direction on how to load/save 
a gif with transparency using CImage?

Currently I'm loading them and then setting the 
transparency index using gif header, but can't get them 
to save correctly at all, even if I rewrite the 
background color in the header.

Thanks,
Scott

0
kermit1 (12)
12/29/2003 1:50:14 AM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
1648 Views

Similar Articles

[PageSpeed] 24

Hello Scott,

Thanks for your post. We will look into it and reply with more information 
here. Please post here 
if you have any more concerns.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

0
timhuang (89)
12/29/2003 11:27:21 AM
Hi Scott,

Thanks for you posting in the group!

>Currently I'm loading them and then setting the 
>transparency index using gif header, 

How do you load GIF and set the transparency index using GIF header?
Would you please paste some code snippet to instantiate your problem?

BTW, If you use the CImage class to handle the GIF image, I suggest a 
sample project on the usage of that class:
http://www.codeproject.com/bitmap/trans_cimage.asp?target=gif%7Ctransparency


Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Third-Party Link Disclaimer

This response contains a reference to a third-party World Wide Web site. 
Microsoft is providing this information as a convenience to you. Microsoft 
does not control these sites and has not tested any software or information 
found on these sites; therefore, Microsoft cannot make any representations 
regarding the quality, safety, or suitability of any software or 
information found there. There are inherent dangers in the use of any 
software found on the Internet, and Microsoft cautions you to make sure 
that you completely understand the risk before retrieving any software from 
the Internet.



0
v-garych (605)
12/30/2003 6:30:59 AM
Hi Gary,
I found that link when I was initially researching the 
problem. I believe that's a different CImage class.

I've been through the ATL code, and the bits are copied 
for the palette, but the alpha bits are not used in the 
GDI bitmap, and no transparency index initialized.

I'm using:

CImage img;
img.Load(picPath);

to load the bitmap. If it's a gif, I grab the header and 
info block from the file and use img.SetTransparentColor
(...) set to the background color field value if the 
packed field indicates it's valid.

To save I was trying to do essentially the same, after 
the img.save(tempPath), I write the packed field to 
indicate the tranparency is valid by using | 0x80, and 
set the background color field, but it doesn't work. I've 
confirmed the changes are written. At present I'm 
attempting to use Gdiplus::Bitmap.Save(), to see if it 
supports writing the transparent values, but I need to 
figure out the encoder parameters first. More header 
reading.

Thanks,
Scott

>-----Original Message-----
>Hi Scott,
>
>Thanks for you posting in the group!
>
>>Currently I'm loading them and then setting the 
>>transparency index using gif header, 
>
>How do you load GIF and set the transparency index using 
GIF header?
>Would you please paste some code snippet to instantiate 
your problem?
>
>BTW, If you use the CImage class to handle the GIF 
image, I suggest a 
>sample project on the usage of that class:
>http://www.codeproject.com/bitmap/trans_cimage.asp?
target=gif%7Ctransparency
>
>
>Best regards,
>
>Gary Chang
>Microsoft Online Partner Support
>
>Get Secure! - www.microsoft.com/security
>This posting is provided "AS IS" with no warranties, and 
confers no rights.
>--------------------
>Third-Party Link Disclaimer
>
>This response contains a reference to a third-party 
World Wide Web site. 
>Microsoft is providing this information as a convenience 
to you. Microsoft 
>does not control these sites and has not tested any 
software or information 
>found on these sites; therefore, Microsoft cannot make 
any representations 
>regarding the quality, safety, or suitability of any 
software or 
>information found there. There are inherent dangers in 
the use of any 
>software found on the Internet, and Microsoft cautions 
you to make sure 
>that you completely understand the risk before 
retrieving any software from 
>the Internet.
>
>
>
>.
>
0
kermit1 (12)
12/30/2003 11:46:15 PM
Hi guysmiley

Thanks for your quickly reply!

To isolate the problem, I need some code to perform more research on your 
program.

Would you please upload a small self-contained project which can repro the 
problem on your side if possible and convenience, or a sample program link?

Thanks and Happy New Year!


Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

0
v-garych (605)
12/31/2003 9:39:00 AM
Hi Gary,

The shortest example would be:

CImage img;
img.Load("C:\\some.gif");
LONG tcolor = img.GetTransparentColor();

tcolor will always receive -1 even if the GIF file is set 
for a transparent background. The problem is also found 
in PNG files.

The problem is in the ATL CImage Load and Save code. In 
the Load, it makes a GDI palette without initializing any 
transparency info, and in the Save, it uses the GDI 
bitmap's palette which doesn't contain any transparency 
info. I've bypassed both using my own code based on the 
GDI+ Image Load and Save and it works fine, so it's 
obviously supported in the encoder/decoder, just not the 
ATL CImage code.

This should either be classified as a bug, or ammended in 
the docs somewhere for the ATL CImage class, since the 
docs currently note transparency is supported for 4 or 8 
bit indexed images, but fail to note it can't load or 
save them. If you would like the code that fixes it, let 
me know and I'll make it available on the net.

Thanks and Happy New Year to you too.
Scott

>-----Original Message-----
>Hi guysmiley
>
>Thanks for your quickly reply!
>
>To isolate the problem, I need some code to perform more 
research on your 
>program.
>
>Would you please upload a small self-contained project 
which can repro the 
>problem on your side if possible and convenience, or a 
sample program link?
>
>Thanks and Happy New Year!
>
>
>Best regards,
>
>Gary Chang
>Microsoft Online Partner Support
>
>Get Secure! - www.microsoft.com/security
>This posting is provided "AS IS" with no warranties, and 
confers no rights.
>--------------------
>
>.
>
0
kermit1 (12)
1/2/2004 7:20:44 AM
Hi guysmiley,

Thanks for your quickly reply!

It seems a problem to the CImage.Load()/Save() method, now I have reported 
this issue to the product team and waiting for their feedback, perhaps it 
will need some time.
If I get any response, I will reply to you as soon as possible.

And meantime, we will very appreciate if you can share your valuable 
revised Load()/Save() function code with the community members.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

0
v-garych (605)
1/2/2004 8:50:16 AM
Hi Scot,

Thanks for your feedback on it.

After looking through the atlimage.h file, it appears that the 
m_iTransparentColor member (which is what is returned after the call to 
GetTransparentColor() ) is automatically initialized to -1 when the CImage 
object is created. It The only way we can change that is by calling the 
SetTransparentColor() function. 

So yes, I agree with you that we should notify the product group about 
this. I will contact them on this problem to see how to document this 
behavior.

Thanks again for your feedback. If you feel there is any we can do, please 
feel free to post here.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! �C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

0
yhhuang (111)
1/9/2004 6:12:15 AM
Yan-Hong Huang[MSFT] wrote:
> After looking through the atlimage.h file, it appears that the
> m_iTransparentColor member (which is what is returned after the call
to
> GetTransparentColor() ) is automatically initialized to -1 when the
CImage
> object is created. It The only way we can change that is by calling
the
> SetTransparentColor() function.
>
> So yes, I agree with you that we should notify the product group
about
> this. I will contact them on this problem to see how to document this

> behavior.


Has there been any further developments on this issue since a year ago?
We've just run into this problem, and I wouldn't mind a
Microsoft-sanctioned fix if there is one...

Jonathan Brecher
CambridgeSoft Corporation
myfirstinitialmylastname@cambridgesoft.com

0
12/28/2004 3:19:26 AM
Reply:

Similar Artilces:

loading network card information ...error provider load failure
This is a multi-part message in MIME format. ------=_NextPart_000_000F_01CA7D92.03F9F310 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi there, I get "loading network card information ...error provider load failure" = when I go and use systeminfo.exe . How can I fix this? Thanks, Gordon ------=_NextPart_000_000F_01CA7D92.03F9F310 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN&qu...

OWA (Not Loading)
Does anyone know of any issues with Satellite Service and the right side of OWA not loading. The left side loads but the user cannot see anything on the right. OWA works from any other connection. Thanks, KG ...

SOS,how to load a invalid or damaged .gif file to create Image Object.
hi everyone. my question is this:how to load a .gif image file that is invalid or damaged image format? Notice,I want to load the invalid damaged image file to operate it. my code is below,but all of they are not correct. -------- 1.Image.FromFile(fileName);load from a file directly,it throws a OutOfMemoryException.In msdn,it's mean the file is a invalid image format. 2.Image.FromStream(stream);load from stream,it throws a ArgumentException. -------- ps:IE and Google Picasa can load and display the damaged .gif file correct. Or there is any other methods to operate the i...

How do I recover excel document prior to auto-save?
I opened an Excel document and made changes, I then "saved as..." and saved it as a different file name. I then closed Excel (without saving). When I went to open the older Excel file it had all the changes that were made when I "saved as...". HELP! ...

Error loading CRM 3.0 Client with Outlook
I receive error message "An error occurred loading Microsoft CRM Functionality" when starting Outlook with CRM 3.0 client installed. I have uninstalled CRM, Office, and cleaned the register using Register Mechanic. I am now getting the same error with an event error "A problem occurred initializing Microsoft CRM COM interopt". Anyone have any ideas? Thanks. I have the exact same issue has anyone found a solution to this? I am running all avialable updates on both Office 2003 and XP Pro, I DO NOT have the Business Contact Manager for Outlook installed. "rtop...

loading web application project suddonly takes 5 mintues and says "Contacting server to open Web project.." wile it takes 5 minutes to load. how to fix? i tried reregistering asp.net and iisreset. no
loading web application project suddonly takes 5 mintues and says "Contacting server to open Web project.." wile it takes 5 minutes to load. how to fix? i tried reregistering asp.net and iisreset. no progres. ...

Error on saving Notes
I have again and again the case, that when I edited some Note and at the end want to close the window, that I get an error saying (paraphrasing from memory): "Error in messaging interface, The note will be closed and the changed content will be lost". Luckily at this point the alert offers a "cancel" button which allows me to keep the window open. I then copy the just edited note's content into a text editor and keep it there. Then I close the Note window (whose content is indeed lost). I close and reopen Outlook and then create the note again (or change its cont...

Data loss when saved as CSV
Hi, An Excel file contains data which comprises of Japanese characters. Using VBA, i read the .Xls file and save part of the data as anothe .CSV file. If i open the new CSV, the Japanese characters and displaying a "?????". Is there any way to supress this behaviour? Regards mtpSures -- mtpsures ----------------------------------------------------------------------- mtpsuresh's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3181 View this thread: http://www.excelforum.com/showthread.php?threadid=55883 ...

'Document not saved'
Ok, here is the situation. I created a template that has about 1 sheets in it, about 1 mb in size, and it contains buttons and a comb box as well. Occasionally a user will try to save and get a 'Documen not saved' dialog and it will not save. When we close it and repeat th same steps it works fine and all is good. Now, however we have a use who gets this everytime. We have looked all over the net and tried th following: -Checked his disk space, tons left. -Cleared out all his temp directories as excel dumps lots in thes (even doc and settings\local settings\temp) -reinstalled, and ...

What do I load ?
Hello. I'm trying to develop a web comsuming client using VS.NET 2003(VB), .NET Framework 1.1.4322, ASP.NET 1.1.4322, WSE2.0 on a WinXP Pro Sp2 comuter. If i comsume this web service: https://xatanet.net/xatanetwebservice/tripexportservice.asmx and do this operation: RetrieveArchivedTrips using: Dim strDate As Date = "2006-04-01" Dim endDate As Date = "2006-04-28" proxy.RetrieveArchivedTrips(strDate, endDate) What do I load when i use the following statements in my program: Dim doc as XmlDocument = new XmlDocument() doc.Load() Any...

Unable to save GIF images as GIFs
Hello, I sometimes receive animated GIF logos inserted directly within the body of an e-mail (ie: via Insert: Picture : From File). I used to be able to save them in GIF format but all of a sudden (perhaps it was after I upgraded to Office XP) I am only able to save them as BMP's. Is there a problem on my end or does Outlook not allow you to save GIF images which have been inserted into an email as GIFs? I have cleared my cache, and I do not have this problem in IE. If anyone knows an answer to this, please help. Ken ...

Debug image fails to load.
Hi, I created an OS design with KITL, Kernel debugger enabled in Debug mode. But when i try to load the image to the CEPC it fails to boot. I am attaching the log here. ------ SERIAL PORT LOG starts ----------- Microsoft Windows CE Ethernet Bootloader Common Library Version 1.0 Built Dec 9 2002 18:35:13 Copyright (c) 2000-2001 Microsoft Corporation Microsoft Windows CE Ethernet Bootloader 3.3 for CE/PC (Feb 6 2003) Boot Args @ 0x1F136 and ucLoaderFlags is 1 PCI Device Configurations (3 PCI bus(es) present)... ======================================================== Bus, Devi...

Click on a link and a picture loads in cell depending on which link you have clicked
Hello If I have five links in cells A1:A5 with peoples names. How can get... e.g. If I click on Bill in A2 then a picture of Bill loads in cell D1 an then click Mark and a picture of Mark loads in D1. Thanks in advanc -- Message posted from http://www.ExcelForum.com I'm not sure what you mean by link in A1 through A5, but I'd try it this way: Put all 5 pictures on the worksheet and position them where you want them. Name them to match the values in A1:A5. Select the picture for Bill and then type Bill in the name box (to the left of the formulabar) and hit enter. After all 5...

Budget Savings Goals
I posted this earlier, but have still not had a resolution. I'm using the advanced budget. I have all my scheduled deposits and expenses set in the bills section of money. These have all been accounted for in the budget (both income and expenses). On the expenses screen, it shows an amount of approx. $1000 left over. When I click next to get to the next screen, "savings goals," it tells me I have $3600 of unbudgeted income left over to spend per month. How is that possible? When I look at the annual report, it tells me I have budgeted $80k in income and that isn't even...

Saving files to memory stick
Hi, I am wanting to save a lot of individual files from a web based program to my memory stick, once I click on save they are in a Microsoft Word format - I then have to select my memory stick before I can then save. Is there a way of making my memory stick the default save location so I don't have to select it every time? Thanks Never save or write files directly to removable media. You risk ending up with corrupt files. -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "Jon" <Jon@discussions....

Loading Error
Hi I am logged on as Domain administrator and have installed Office 2000 twice over.. I am getting the following error, and I have put it into Microsoft Support but it comes up with nothing. The error is "Unknown Error 0xAF54011D You Do not have permission to log on" any Ideas thanks It helps telling where you get this error and where you are trying to connect to. -- Roady [MVP] www.howto-outlook.com Tips of the month: -Setting Permissions on a Mailbox -Create an Office XP CD slipstreamed with Service Pack 3 ----- "News" <sasa@sdfad.com> wrote in message ...

Ev�nements Load et Unload
Quelqu'un peut-il me dire pourquoi je n'arrive pas � s�lectionner les �v�nements Load et Unload dans la partie droite de mon UserForm (et ce qu'il faut faire). (Je n'ai pas d'�v�nements Load et Unload dans la partie droite de ma liste, la partie gauche ayant le nom UserForm). D'avance merci, Jean-michel ...

How to save time updating cost prices
Help please I have a Sheet with some 600+ stock items on it SHEET1 Stock Ref SuppRef Desc Note Selling Supplier Cost Price Price AA999B VP2ER4 Widget11 abc123 0.84 Company1 1.40 AB999C VP2RR7 Widget13 rst33j 1.25 Company2 2.65 SHEET2 Stocktype percentpay Note Largewidgets 73 Last updated 30/08/04 Smallwidgets 79 Last updated 30/08/04 the stocktype column A is transfered so that column B has a label equating to the name in colu...

While loading
I want to show a welcome screen while the application loads in the back ground. How can this be done? Thanks. Jess look at this:- http://www.codeproject.com/dialog/dialogspl.asp -- Vipin Aravind http://www.explorewindows.com "Jessica Weiner" <jessica@gmail.com> wrote in message news:jA8Qf.44094$F_3.26672@newssvr29.news.prodigy.net... >I want to show a welcome screen while the application loads in the back >ground. How can this be done? > > Thanks. > Jess > PJ's website has a nice class for this... obviously if you Google "Splash Scree...

Quick-Access-Toolbar Settings: SAVE on other PC ?
HOW to save my Quick-Access-Toolbar SETTINGS ? Best on a stick, to work with on an other PC? Thanks. If the QAT settings are in your normal.dotm, save it under a new name. Save the file to the Word/Startup folder that is along the user path for your user name on that computer. It will load whenever you start Word. You can save the QAT dotm in other locations, but you will have to load it yourself every time you start Word. Most of the experts here recommend that you _not_ load the add-on template from a "stick". Pam jsyh wrote: >HOW to save my Quick-Access...

Drop-down lists loading
Hi, I have several huge drop-down lists (countries for several forms,applications etc.) to load into the CRM. The only way to do that, I found is manual typing. Any ideas how I can do that in the automatic way? Thanks. You could use the SDK to do it programatically. How long is the list? Problem is by the time you have written the code to do such a job you usually could have typed the data in. "innab" <innab@nur.com> wrote in message news:0ca201c36bcf$1629b420$a401280a@phx.gbl... > Hi, > I have several huge drop-down lists (countries for several > forms,applicat...

Excel XP Saving Issues
Good morning. We are having an issue with a user who has just been upgraded to Office XP. She is using Excel and updated some of her worksheets and saved frequently. She noticed the day after one of her workbooks did not save all data. It saved the last changed she made to a worksheet, but none of the previous changes to a seperate worksheet. So assuming if it saved the last part she changed it should have saved the first changes. Has anyone had this issue with upgrading to Office XP and having save issues? Please help. Thanks. ---Woodstok No one has reported anything like t...

OWA not loading
On E2K, while using OWA (after login), It’s getting stuck on “Loading” screen. What could be wrong? TIA Try this: http://support.microsoft.com/?kbid=280823 -- Neil Hobson Exchange MVP For Exchange news, links, and tips, check: http://www.msexchangeblog.com "Sam" <Sam@discussions.microsoft.com> wrote in message news:A25FA6E8-1560-4969-9494-44BB7FA54936@microsoft.com... > On E2K, while using OWA (after login), It's getting stuck on "Loading" > screen. What could be wrong? > TIA > ...

How do I recover Excel document printed but not saved
I created a large Excel spreadsheet, saved it at various stages, and then printed the finished version. I then made a change I didn't want to keep, so closed the document and clicked No when asked if i wanted to save changes. Unfortunately I hadn't saved the most recent changes before I printed the document. Is there any way to recover the printed version of the document? Scan in the paper copy?? If you didn't save it, there's nothing to go back to. Richard AH wrote: > > I created a large Excel spreadsheet, saved it at various stages, and then > printed the...

XSD, complexTypes, SQLXML bulk load: What am I missing?
Hello Techies-- I am reading an XML document with many nested elements. Many of these elements go to such a variety of tables, that I am trying to simply the read of the document by dumping the data into a single table using SQLXML/BulkXMLLoad. I have triggers set on an insert of this table to cascade inserts to the appropriate myriad of other tables. Originally I tried to use simpleType, then I tried to use: complexType, mixed="true" when setting up the schema, but received errors from SQLXML stating that mixed type cannot be used. The bottom line: For every level of sequenced ele...