I'm trying to build a small C# Windows Form, graphics program and I need to save/load sprite sheets. I've searched but can't find a standard file format for sprite sheets, I have however found the .sprite extension.
So my questions are:
Is there a standard format for a .sprite file (e.g. header 15 bytes and contains the length of etc...)
Is there a different file format I should be using for sprite sheets?
I have personally never heard of a .sprite file extension; Googling it seems it may be used for the Scratch language (https://en.scratch-wiki.info/wiki/Scratch_File_Format#Sprite_Files).
Typically though, spritesheets are just image files with multiple images on them. PNG files seem to be the most common, though there is no real reason you couldn't use basically any image file type (though keep in mind some may not have alpha channels, etc.). Most software that packs spritesheets will output in a PNG, and will either split it up based on a grid system or provide a catalog of information (often in JSON format) for splitting the sheet into the subimages you need.
Related
I have a task to programamatically scan a folder for georeferenced images. There might be a lot of images, some quite large, and some not georeferenced. The spatial information can also be either embedded or in a world file.
How can I tell programmatically (C#/WPF/ESRI Runtime) if "C:\someFolder\file.x" is georeferenced?
Thanks
First check the file type to see if it's a format that supports built in georeferencing (GeoTiff, jp2, and MrSid). Other static image files would need some sort of companion file with the georeferencing information. So for each image file you'd want to look for a matching companion file.
If you add some info on what formats the images/world files are in it'll be easier to show you some sample code.
I need to convert different files formats into .png grayscale (8 or 16 bit) format. I have found tools that can convert documents, PDFs and text docs.
I was looking into Aspose Imaging for .Net but the API converted grayscaled images are actually larger than the actual files for .jpg, png and tif formats. I want to make them as small as possible, which is part of the requirement.
I have looked into image magik, but our company does not allow open source software in our web service development.
If I use more than one tool for this conversion, will my WCF application get affected? I am sure I will have to use thread safe API's because multiple objects of this application will be running on the server.
Thank you
Went with Aspos converter, their product is good but service is not that great. Also looked into snowbound, it wasn't that great.
In .NET suppose I have an application that can create and open an image that has its metadata defined in a seperate file (i.e. '.json'/'.xml'). It would spit or open the metadata file of the same name as the image file.
Now to make distribution of the image + metadata files easier, I want to eliminate the extra metadata file so that users can open an image and has all the relevent info about the image. What are some of the good strategies for embedding the data into the image file itself?
Here are a few possibilities I found by googling:
Visual embedding:
Data encoded as 2D Barcode such as QR Code, Data Matrix or PDF417.
Data drawn as plain text on the image, retrieved through OCR
Format embedding:
Data inserted as JPEG comments/EXIF comments
Data inserted as PNG text chunks
The basic requirements are:
Data can be in JSON, XML or binary format, as long as it's machine-readable.
Data can be in the KB's, up to several dozens of KB's. The more the better.
For visual embedding:
Data should hold up well against a certain degree of lossy compressions.
The shape of the data 'zone' on the image's canvas should be as flexible as possible to better use the image's real estate.
Support all common image formats. (bmp, jpg, png, gif, etc.)
If possible, use open source .NET libraries.
Any advice welcomed. Thanks!
One way to do this is to store the information as a string of XML in the EXIF portion of the .jpg file, maybe in the UserComment field (9286H) of the EXIF IFD.
Here is some info on loading and saving metadata using gdi+.
I have problem with image compression. I need to compres a lot of files (700-900kb) to files 70-80kb without
loss of quality. (or small loss ) I found menu item "Save for Web & Devices ..." in Photoshop. It works great.
But I don't want to use photoshop programmatically. May be someone knows how to solve this problem with
other third party components or frameworks?
Thanks for any ideas!
.NET has a number of image decoding/encoding libraries, often tied to a particular GUI framework (e.g. in Windows Forms you have System.Drawing.Image and for WPF, see the Imaging Overview chapter on msdn).
There are also third party libraries specialized in image conversion/compression that you can find online (both free and non free)
Generally though, the amount of saving you get from compressing an image highly depends on the original format. If you already have JPEG photos with normal compression (quality of 85%) then there is not much you can do in terms of making them smaller except resizing them. If you have raw bitmaps (e.g. BMP, uncompressed/low compression TIFF etc.) then you can expect quite large savings with most compressing formats
When choosing image format, consider this:
Photos and similar: JPEG will often do fine. Good savings with reasonable quality loss
Screenshots and similar: PNG will generally give best results (PNG is lossless). JPEG will often create highly visible artifacts on screenshots
Compressing an already compressed image (i.e. PNG, JPEG etc.) with a general purpose compression algorithm like ZIP or RAR will in practice not give you any savings. You may actually end up with a bigger file.
You can have a look at the FreeImage project. It has a C# wrapper that you can use.
Imagemagick allows you to batch-processing on files and offers a everything you could possible ask for when it comes to handling of images
E.g. to resize every image in folder (destroy originals) to QVGA do
mogrify -resize 320x240 *.jpg
To preserve aspect ratio do
mogrify -resize 320x240! *.jpg
If you need to traverse a directory structure, this is how you can do it in *nix based systems (also destroying originals)
find . -type f -name *.jpg -exec convert -resize 800x800 {} \;
There is also an quality switch available, see here
I'm having issues with TIFFs
Here is what I have to do, we have tiff images saved into the database, these images are CCITT4 compressed with a number of required tags, these include:
RowsPerStrip must be the ImageLength
Photometric Interpreation must be MinIsWhite
Multi-strip image format is not allowed
My problem is, I'm using the built in System.Drawing.Bitmap/Image objects, which happen to change the values of these when I put it into the object, I've tested this by saving the byte[] to a tiff directly from the database, checked the tags, they are fine.. but when i put the bytes into an Image object then save to file, they are modified.
To make things worse, I'm needing to add a text to the image before saving it.
So I need a component that will allow me more control with TIFF (and they must be tiff), and be able to add text to an image or be able to use the Graphics object.
I've tried using LibTiff but I have yet to see any examples on how to use this component,
any suggestions?
You can use our free and open-source LibTiff.Net library for this. It is freely available for all uses under a BSD license. The just released version 2.0 contains good documentation and number of samples.
There are samples that show how to convert any non-tiled TIFF image to the TIFF image which have all data written in a single strip and how to convert a System.Drawing.Bitmap to 1-bit CCITT single strip TIFF image.
I have never used the built int System.Drawing.Bitmap objects to do this. I personally use LeadTools, but it isn't free. It is however a robust and fairly straightforward API. I primarily use it for GEOTiff which contain specific data tags for image location data.
There is a 60 day evaluation if you would like to try it out.
I use FreeImage. There's a C# .NET wrapper available too.
The IEvolution component set from HiComponents is now totally free (no source) - http://www.hicomponents.com. A very powerful .NET imaging toolkit.