Native PNG library on MacOSX (mavericks) - c

I need to build an application which can read PNG files. On MacOSX mavericks the libpng is not available anymore (see).
Is there any other way to read PNG file on MacOSX (Cocoa / Carbon Framework...). I'd rather stay with the native framework than download and compile a local libpng. I also need to read TIFF and JPEG files, so ideally the native framework would also allow me to read those ? I am using C programming.

I would expect that to be handled by the (aptly named) Image I/O framework. This page has example code on how to set up an "image source" and load an image from it. I don't think you need to care at the application level whether the image is PNG or not, the framework abstracts that out.

Related

Protect TTF Font files by making them unopenable, but still work on as webfonts

I'm a font maker and I want to protect my web-fonts.
I know about the HTACCESS way to protect font files, but I found that there is another way to protect web-fonts: making the TTF font files intentionaly corrupted when you try to open them with Windows Font Viewer so they won't be installable, while the the same exact file will still work as webfont in the browser.
Here's a working example I have found (how they did it is the mystery):
http://fontface.co.il/fonts/demo_s.asp?id=131
As you can see, you are able to access the font files if they are cached in your browser, but when you download the TTF file and open it via "Windows Font Viewer" in order to install it, it will give you this error: "The requested file _____.ttf is not a valid font file".
You can test it yourself in your computer and you'll see that the web font will still work only with the TTF. (without including the woff / eot files in #font-face)
That's exactly what I want to do to my own fonts.
That way they would still work as web fonts, and will not work as desktop fonts, making it harder for untrained people to install them without a license.
However, I can't figure out how they did it.
Any ideas?
The OS has different requirements for what constitutes as a valid font than a web browser. A web browser is more lenient when the font misses certain pieces of data. The trick is to figure out how much you can "mangle" a font so that it's not installable, but still passes OTS and is usable in a browser.
On the webpage indicated as an example, the font is served in Embedded OpenType format.
Embedded OpenType (EOT) fonts are a compact form of OpenType fonts designed by Microsoft for use as embedded fonts on web pages. [...] These font files can be created from existing TrueType font files using Microsoft's Web Embedding Fonts Tool (WEFT), and other proprietary and open source software. [...] The font files are made small in size by use of subsetting (only including the needed characters), and by data compression (LZ compression, part of Agfa's MicroType Express). (Wikipedia)

Save HBITMAP as PNG image using GDI?

I'm looking to save an HBITMAP to a PNG image. Is this possible using only the GDI API? (I'm using C, so no GDI+.) I have only found examples like this, to save to a BMP file. Or should I use libpng and use GetDIBits?
Related question (about reading).
Unfortunately, GDI does not support PNGs.
The Microsoft Windows API does not expose any c++ classes directly from DLLs - The c++ standard does not define an ABI, and as such, the calling conventions and name mangling's used are left to specific implementations to define.
As such, up until Metro at least, all "C++" interfaces supported by the Windows OS have actually been a regular dll exporting a C compatible API, and an accompyining set of c++ header files with the necessary template and inline code.
As such, GDI+ has a Flat API documented in MSDN.

Create a bmp of a string using a TTF file using C?

I have a new project assigned to me today. I need to load a TTF file and then write the specified string to a bitmap using that font. However, I do not have much information about the TTF structure. Is there any library specifically for this job?
I suggest you have a look at the SDL_ttf project. SDL is also a good start to build a small gfx app.
Here is also a useful tutorial aboud using SDL_ttf in OpenGL and rendering text as textures.

How to Convert TIFF to JPG Inside Silverlight, client side, using a control or a class/function?

We are creating a client in Silverlight that will show a lot of TIFF images. Silverlight natively do not support TIFF. I need a control/class to convert tiff to jpg in runtime inside the Silverlight client. Any idea?
In Silverlight forum last friday I received this post:
Re: How to Convert TIFF to JPG Inside Silverlight, client side, using a control or a class/function?
12-18-2009 5:38 PM |
If you're willing to use a third-party library, check out ImageGear for Silverlight provided by Accusoft Pegasus. It's a 100% managed Silverlight toolkit (http://www.accusoft.com/ig-silverlight.htm), and runs entirely on the client. TIFF support is included (among lots of other formats).
Hope this helps,
Casey
I was successful displaying TIFFs in Silverlight. It's easy to port the free LibTiff.NET library to Silverlight, just 3-4 minor tweaks required.
The library itself is quite legacy-like and raw to use and one still needs to have some knowledge about the inner workings of the TIFF format in order to be able to extract the image data the way one needs it.
But it's doable and the bits and pieces can then be chiseled into a WriteableBitmap.
Not sure you are interested in solution by now, but we've just released LibTiff.Net 2.0 with Silverlight support, improved documentation and samples.
There is Silverlight Test Application in source package that shows how to create WriteableBitmap from TIFF images in Silverlight. Maybe it will help you or others.

How to generate thumbnail for some pages of a PDF file?

I want a C library for generating image snapshots of PDF files. Then I would use this to generate the thumbnail of the first page. Is there a library for this?
You could probably use one of the general-purpose PDF libraries:
Ghostscript - C, available under the GPL
Poppler - C++, available under the GPL
Adobe PDF Library SDK - expensive
Google reveals quite a few PDF-to-image converters which you may be able to incorporate if one of the above options doesn't work.
Check out Poppler --- a PDF rendering library based on the xpdf-3.0 code base. It comes with a tool to create images from PDF pages as well.

Resources