what's the difference between an ico file and a png icon file - wpf

For windows programming, can I use PNG file as icon?

No.
An ICO is actually a specialized file format that contains a collection of images at potentially many different sizes and color depths. A png is a specific image.
What you can do is create an .ico from a .png. I've found IconMaker convenient for that purpose.

Well, the difference is that they are different file formats :-).
As to using them as icons on MS Windows:
Only Vista supports PNG icons out of the box; for earlier Windows versions, you will have to use .ico files. There are however many converter programs. So your best bet probably is to internally store icons as PNG during development (as it is a superior format), then convert the icon to .ico during your application's build process.

Related

Is it possible to replace the 'native fonts' in the simulator with a specific font?

I would like to record an 'iPhone' demo in the simulator, but the font is not the same as on the device (I know you can't distribute it). However, I found the SF Pro font for download and wanted to give it a try and was wondering if there is a simple way to override the native fonts easily (without having to change e.g. the css file)?
So that I can leave statements like this in my CSS: font-family: "native:MainRegular" but programmatically set this to be my copy of SF Pro font in the Simulator...
I wouldn't do this since font kerning will look "off" and if someone will notice the font he'll notice that as well. The same font will look different in Windows, Mac etc.
But if you insist then the simplest way is to create your own skin file. This is just a simple zip file containing the skin details. E.g. this is the iPhoneX skin. Notice it doesn't include TTF files within...
You need to add the fonts you want then use something like the google pixel skin as a reference. Look in the properties file on defining the fonts. It's pretty simple.
As you can see from the script building the skins is literally just zipping.

Using Visual Studio Image Library PNGs in a Windows Form app

My question is about the Visual Studio Image Library that comes with VS2008. In the _Common Elements\Annotations folder, there are PNGs with multiple sizes and I was wondering what the intended use of these is. Is there an standard way to implement these images, e.g. in a Windows Forms status bar?
Here are three of the PNGs as an example:
The suggested usage is to basically copy/paste the sized image you want into a new image file. Then simply use that as an icon or image in your controls as you see fit. All of the PNGs already have a transparent background, so it should be really easy to copy/paste.

Does WPF support reading/writing WMF/EMF files natively?

Can Windows Presentation Foundation read/write WMF/EMF files without having to use WinForms Interop or Win32.
If it does not, what is the reason?
A quick search on MSDN reveals a thread containing a post by Peggi Goodwin, a PM at Microsoft:
WPF does not support the EMF and WMF image formats. These formats are more susceptible to security vulnerabilities than other image formats, so we do not intend to support them.
I did it !!!
I'm using ComponentOne's WPF chart in my real code but to keep the example simple I just did a button. But it DOES work on Complex wpf widgets. Fonts, Transparency, AntiAlias etc. everything works. And I can paste into Word and change labels on charts etc.
Basically I decimate the XAML to XPS then import it back into XAML.
Then I used an open source project that converts XAML to WMF called XAMLToys.
XAMLToys would fail 99% of the time because you cannot serial complex XAML objects
http://softronix.com/download/WpfToWmfClipboard.zip
Big kudos to these two projects
http://xamltoys.codeplex.com/
http://khason.net/blog/converting-fixeddocument-xpsdocument-too-to-flowdocument/

Icon display in WinForms app

When an application icon is displayed, is it Windows who decides which version (bit depth) to use or is it somehow set in the ICO file?
If I create an ICO file only with 32bit colors (24bit + 8bit transparency), the icon displays fine on Win XP. If I add for example 4bit version, Windows use always this 4bit version, even if there are 32bit images as well. My monitor is set to 32bit colors. I am using Greenfish Icon Editor if this is any important.
Is there any way how to push Windows to use the 32bit icons instead of the 4bit ones?
EDIT: I used IcoFX to just open the original ICO file and re-save it and now Windows always chooses the right bit depth. Interesting...
It's chosen by Windows based on the bit-depth of the surface it's drawn onto. It also depends on the actual order of the icons inside the .ICO file (or resource), that's why you get different result with IcoFX.
Windows will use the icon with whatever bit depth it can display, so your understanding of how things should work is correct.
I've not used Greenfish, so don't know if it is creating the icon file correctly. If you're using VS2008 you could try the (free) Axialis IconWorkshop to double-check the icon file (they have a non-free standalone version also).

Getting .png pixel data in Silverlight

We have a Silverlight application that needs to load a number of .png files. We can load the images OK, but Silverlight doesn't support reading the pixel data from the Image class.
Can anyone suggest a simple solution for getting at this data? Our current best bet would be a third party .png loading library, but we are having trouble finding a suitable one.
There is no built in classes for doing pixel based imagine manipulation/generation i n Silverlight. You need to implement your own PNG Encoder/Decoder that works on an byte array containing the image information. Joe Stegman has implemented one such encoder you should check out. He got lots of great information about "editable images" in Silverlight over at http://blogs.msdn.com/jstegman/. He does things like applying filters to images, generating mandlebrots and more.
This blog discuss a JPEG Silverilght Encoder (FJCore) you can use to resize and recompress photos client size: http://fluxcapacity.net/2008/07/14/fjcore-to-the-rescue/
Another tool is "Fluxify" which lets you resize and upload photos using Silverilght 2. Can be found over at http://fluxtools.net/
So yes, client side image processing can definitely be done in Silverilght 2. Happy hacking!
PNG decoding is hard to find.
I wrote an article for MSDN that includes some open source code I cobbled together from Joe Stegman, FluxCapacity, and a few others. It includes PNG decoding (as well as GIF, JPG, and BMP) for those in this thread that are looking for that.
http://www.microsoft.com/youshapeit/msdn/ExpertKnowledge/2008-10/InnovateWithSilverlight2.aspx
If you don't care for my implementation of it for Silverlight, then you can go straight to what I modified for PNG decoding: http://sourceforge.net/projects/pr2/
Cheers!
Update: It looks like they no longer offer the source code on the site, so I re-posted the content here:
http://dimebrain.com/2009/01/innovate-with-silverlight-2-article-code-available.html
Thanks - I've seen the Joe Stegman blog. It's very handy, but the decoder he doesn't have is a PNG one. We're using PNGs as we need transparency. The fluxtools link seems to be broken too.
I'm still looking (unsuccessfully) for a PNG decoder I can drop into Silverlight.
One option that may (depending on circumstances) be easier is to save the color data and transparency data separately, then programmatically apply the transparency to the image once you have it loaded. That way, you could save the image as a 8-bit gif representing the alpha channel, plus a jpg or bmp or whatever for the color data.
Dimebrain - that msdn link you provided doesn't have a valid link to the sourcecode - any chance you have a link to the source that works?

Resources