Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > TreeView handles PNG files badly
 

TreeView handles PNG files badly

Hi;

I give our TreeViews 32-bit PNG files with a full 8 bits used to set alpha. It seems to treat it as either transparent or 100% - and anything partially transparent is treated as 100% color.

Does something special have to be done for 32-bit PNG files that do set values in the PNG other than 0 or 255?

thanks - dave

Laugh your ____ off funny - Cubicle Wars
DavidThi808  Monday, August 03, 2009 1:47 PM
Hello Dave,

Thanks for your feedback. I downloaded the png image and performed a test on my side. I create simple C# Windows Form applicaiton and add the TreeView control to the Form, then I used a ImageList to set the png image to the TreeNode inside the TreeView, it word well on my side. However, When I disable the visual style, the png image is render as the screenshot shows. Therefore, please try to add the following two line to eanble the visual style before calling Application.Run to bring up the main form.

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer byDavidThi808 Wednesday, August 05, 2009 3:19 PM
  •  
Rong-Chun Zhang  Wednesday, August 05, 2009 6:45 AM
Hello Dave,

Please let me confirm my understanding with you, you want set a partially transparent png image to the TreeNode using a ImageList. Correct me if there is any misunderstanding.

As far as I know, the default ColorDepth of ImageList is Depth8Bit, which doesn't work well with transparency. Please try to set it to Depth32Bit instead to see if the problem still happens.

If you have any additional question, feel free to post here.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Rong-Chun Zhang  Tuesday, August 04, 2009 8:03 AM
Hi;

I already set it to ColorDepth.Depth32Bit. Any oher ideas? I've seen others complain about this same issue so it should be a known problem.

thanks - dave
Laugh your ____ off funny - Cubicle Wars
DavidThi808  Tuesday, August 04, 2009 2:42 PM
Hello Dave,

Thanks for your effort.

I have performed a test on my side, and it worked well on my machine. Could you please share the png image on some file sharing website and paste the url here? It would be more helpful if you could send out a simple project to reproduce the issue, so that we can investigate it locally. It is not necessary that you send out the whole of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business details from it. I appreciate your work on providing these information.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Rong-Chun Zhang  Wednesday, August 05, 2009 3:21 AM
Please download http://www.windwardreports.com/temp/TreeView-bitmaps.zip- it has a screenshot of the error and the PNG file used.

If you need to see it in use, please get AutoTag at http://www.windwardreports.com/student.htmand 1) Add an XMLdatasource, 2) go into the Tag Builder, 3) click the wizard button. That will show you this error.

thanks - dave
Laugh your ____ off funny - Cubicle Wars
DavidThi808  Wednesday, August 05, 2009 5:17 AM
Hello Dave,

Thanks for your feedback. I downloaded the png image and performed a test on my side. I create simple C# Windows Form applicaiton and add the TreeView control to the Form, then I used a ImageList to set the png image to the TreeNode inside the TreeView, it word well on my side. However, When I disable the visual style, the png image is render as the screenshot shows. Therefore, please try to add the following two line to eanble the visual style before calling Application.Run to bring up the main form.

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer byDavidThi808 Wednesday, August 05, 2009 3:19 PM
  •  
Rong-Chun Zhang  Wednesday, August 05, 2009 6:45 AM
Thank you! that was it.

Have a wonderful day - dave
Laugh your ____ off funny - Cubicle Wars
DavidThi808  Wednesday, August 05, 2009 3:19 PM

You can use google to search for other answers

Custom Search

More Threads

• stuck with string stuff
• DataGridView Cell Format
• auto height DataGridView rows
• TableAdapter with connectionstring programmatically set
• How do I disable the AddNewItem button on the bindingNavigator control ?
• Format only one specified cell of the DataGridView
• Beginner question: dataAdapter.update not working
• moving nodes up and down in a treeview
• How to disable select all (corner-button) DataGridView?
• Validating DataGridView Cell for currenct fields