I noticed the boost::gil::extension::io only supports png or jpeg files.. While this is often enough I'm wondering how to load a bitmap (*.bmp) file into an image? Shouldn't this be actually easier than jpeg etc?
Hopefully you solved it.
Just to add: install latest version of GIL on existing boost and then compile.
The bitmap files comes under new 'io_new' folder.
Related
I am using the ImageMagick C++ api to convert from SVG to PNG. The SVG has a .css file and .ttf fonts are in the input data.
If I add the fonts to the ~/.fonts folder and use the fc-cache command, my conversion works fine. The conversion also works fine if I use already-installed-fonts on my system.
The problem is that I cannot adjust any configuration on the server where it will be running, so i was looking for a runtime solution.
Using fc-cache to point at the directory where the fonts are didn't work for me.
I found the MAGICK_FONT_PATH environment variable and I created a type.xml in the input data fonts folder. Then I pointed the MAGICK_FONT_PATH to the type.xml folder, and when I list fonts with convert -list font I can see the fonts, but using the imageMagick api directly from C++ doesn't use the fonts.
The code is something like:
magickImage.write(&blob);
Does anyone know how to use custom fonts with the imagemagick api? Where the fonts-to-be-used are defined in the .css file?
I found that JPEG2000 has an alpha channel, and I want to change PNG format to JPEG2000 in my project which is based on SDL 2.0.3 and SDL_Image. Is it possible to use JPEG2000 in SDL?
As far as I know there is no support for JPEG2000 in stock SDL_Image. What you can do is find the necessary libraries/headers and implement this directly, maybe using SDL_Image to load your PNGs into surfaces/textures and then writing your own methods for exporting to JPEG2000.
I need to rewrite some lines of uncompressed tiff file.
The probles is that I need to do it without copying entire file to another place.
Only way I found is to read the specifications and write my own code to work with tiff files.
libtiff doesn't allow to open file for read and write.
libgeotiff is libtiff based.
gdal also doesn't allow in place editing of files.
GDAL is the best library to do this.
I need to take a BMP that I have in memory (stored as an HBITMAP or a CImage take your pick), and save it to a PNG file on disk.
Here is how I am currently saving the image as a png.
CImage img;
img.Save("foo.png")
My problem is that is far too slow (250ms for ~1920X1080). This takes 3X the time of saving as JPG, and about 9X the time of saving as a BMP.
I know there are a lot of g++ libraries for linux (e.g. libpng) that will do this, but most of the libraries that support visual studio only support version 6, and I haven't found one with benchmarks, so I'm kind of hesitant to try getting these libraries working only to find out they are too slow.
I am not sure what type of encoder windows uses (it's hidden in a DLL), but there must be a faster one (I'm even willing to sacrifice a bit of disk size, up to twice as much).
Java libraries do this very quickly, but for some reason Microsoft's library is slow as a turtle.
So I was wondering what options I have for saving screen-sizes PNGs to disk in ~100ms?
I'd bet (but I have no bencharks) that libpng is the best option.
At least, I'd seek a library that allows to tune the saving options ( CImage doesn't). There are two relevant options to try:
Zlib compression level (0-9) : the typical default value (6) is usually ok, you'll rarely gain much speed using less compression
Filter type. This can be more important. If we want to optimize for speed, I'd preselect a unique filter (usually PNG_FILTER_PAETH).
It's very easy to compile libpng yourself. I just did it myself before typing this resposne out. It took about 90 seconds.
Download zlib from http://zlib.net/ Either in source or precompiled form such that you have zlib.h
Download libpng from http://sourceforge.net/projects/libpng/files/libpng15/1.5.12/lpng1512.zip/download
Unzip the contents of libpng zip file.
Open a command shell.
"cd /d d:\projects\libpng" (cd into whatever directory you just unzipped the libpng sources from)
"copy scripts\libpng.h.prebuilt libpng.h"
Create a new Visual Studio C++ project (static library) in the libpng directory
Add all the *.c files from the libpng directory to the project
Add your zlib project directory to the project's include path. (Wherever it can find zlib.h)
Build your project. It should compile the png code library just fine. Done.
How can I get a libtiff TIFF object from a MagickWand object (in C)?
I want to open any given image type with ImageMagick and run tesseract on it. Tesseract seems to use libtiff for it's IO, ImageMagick seems to use libtiff for it's tiff handling, so I figured I should somehow be able to use ImageMagick with tesseract without meddling in the filesystem and additional unessesary disk IO.
Thanks,
Chenz
Look at BeginPageUpright() in Tesseract. It takes the image width, height, bpp, and the raw uncompressed data, which you should be able to get from ImageMagick.