Images for file extensions - image

I want the small images of different file formats (docx,ppt,txt etc.) to display along with the file names of corresponding type.
Any link to get these images?
TIA.

If you want to display a file list with the associated icons showing net to the file name in your program, you can use the SHCreateFileExtractIcon Function from the shell extension of Windows. It extracts the associated icon for a given file.
HRESULT SHCreateFileExtractIcon(
LPCTSTR pszFile,
DWORD dwFileAttributes,
REFIID riid,
void **ppv
If you want to have the exact icons that are associated with files at any time, this is the way to go. You could always store these icons you obtain to disc to come up with your own set of icons.

Related

How to save a photo with custom filename using PHPhotoLibrary on iOS/Swift 2?

I'm trying to save an image with a custom filename with PHPhotoLibrary but it for me is impossible. The filename of image always is IMG_XXX.JPG. I get its filename from photos program.
I don't see the filename in my iPhone.
Filenames within the Photos library are an implementation detail. They're not exactly private, but they aren't there as something for you to mess with or rely on the stability of. (For example, if you grab the underlying image file for an asset, it'll have one name, but that name may change if the user edits that asset in the Photos app or it gets uncached and re-downloaded from iCloud Photo Library.)
You can get a filename when you read an asset from the Photos library, simply as a side effect of being able to get an original file. You're not allowed to set filenames in the Photos library, because Photos manages its own storage.
And of course, if you read an asset's original file and want to save a copy of it somewhere else, you can give that copy whatever filename you want.

How to programmatically determine whether a font is CFF?

Alrighty, I promise this is the closest I'll ever get to a "code for me" question :) If this doesn't drum up any responses I'll bite the bullet and build an OTF parser to check for the existence of a CFF table.
This info is available in the Windows font preview ('TrueType outlines' vs 'PostScript outlines'), so presumably there's a WinAPI function to this effect, but damned if I can find it.
Thoughts anyone?
ps - It's not a dealbreaker if only installed fonts can be checked, but checking files would be preferable.
You can do this using the GetFontData function.
Create the font in question and select it into a DC, then call GetFontData to query the size of the CFF table. This will only succeed if the font has PostScript outlines.
DWORD dwSize = GetFontData(hdc, ' FFC', 0, nullptr, 0);
if (dwSize && dwSize != GDI_ERROR)
{
// has PostScript outlines
}
The OpenType spec says:
OpenType fonts containing CFF data should use the tag 'OTTO' as the sfnt version number.
So, if the first four bytes of the file spell "OTTO" it uses PostScript outlines. Could it be simpler!? Tested & working so far, but I'll probably use GetFontData in the end.
Your best bet indeed seems to be to directly read the font tables from the font file itself. This sample here will give to a head start, assuming you're already familiar with the font tables. If not, read the links in the Reference section at the bottom of the article.
The first 4 bytes of a OpenType file who has a CFF block are "OTTO".

Resource pictures not include in directory

I am creating a vb6 application now and most of my command buttons were graphical style. Do the background images still show up even if I remove them from the app folder?
This is part of what goes into .FRX, .CTX, etc. files. Those are resource files created in a private "property bag" type format and are used to hold things like binary data, images, long strings, and so on.
But don't discard your source files, because you may need them down the road. Treat such things as valuable parts of the program source. They are not needed at run time though.
As far a I know it doesn't remove the picture from the command button when you delete it from the app folder, i suggest making a copy of your image and then delete the original and see if it works in case it doesn't you have the backup image, good luck.

C# paint program saving bitmap to different formats

I am working on a program that should be basically a paint program but with the possibility to save the drawn image to like 5 formats or so. So I figured out that in order to save it I need to draw on bitmap. But when I try to save the image, in the drop down menu I have only one option and it shows the two formats next to each other, and it always saves it as .bmp. http://s8.postimg.org/97wj3x2v9/Bez_n_zvu.jpg
I am using a save file dialog. How can I save it to more formats? For example .jpg, .png and others?
This is the code for saving i curently have.
{
saveFileDialog1.Filter = "Image Files (*.bmp, *.jpg)|*.bmp;*.jpg";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
bitmapa.Save(saveFileDialog1.FileName);
}
}
The filter is divided to two parts: description of the filter and the filter pattern.
For each format you need a "filter"(a new description and pattern). So for .bmp, .jpg and .png:
"Bmp Files (*.bmp)|*.bmp |Jpeg Files (*.jpg)|*.jpg |Png Files (*.png)|*.png";
description pattern description pattern description pattern
And if you want a general filter for all three formats:
"Image Files (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png|Bmp Files (*.bmp)|*.bmp|Jpeg Files (*.jpg)|*.jpg|Png Files (*.png)|*.png";

How does GDI function GetFontData know which font?

I have some old code that I want to port to metro. The old code uses the GDI function GetFontData to get font data from a table whose tag is being passed to it. I plan to replace it with IDWriteFontFace::TryGetFontTable.To do so I have to create a IDWriteFontFace object which requires path to the font file corresponding to the font it represents. But what I don't understand is where does GetFontData figure out the font files from whose tables it is supposed to fetch the data from? Does it do so from the device context that is passed to it?
The font is the one currently selected in the Device Context. You can retrieve it by using GetCurrentObject with object type OBJ_FONT. You can then safely cast the returned HGDIOBJ to a HFONT.
As for retrieving the font file name, that's not easy. See that SO Question
There always some font selected in Device Context (I say always because there is default font). So GetFontData returns that font depending on HDC hdc parameter.
As manuell mentioned GetFontData is similar to (HFONT)(GetCurrentObject(hdc, OBJ_FONT))

Resources