I am writing a program in C for file compression. The method i am trying to use involves doing math on the file as if it were one long number. Can anyone recommend a bignum library that would not try to do all of that in ram, but rather let me do math with file pointers. any help would be appreciated, thanks in advance.
I doubt such a library exists. You could try mmap()ing the files in memory and see if you can do it that way.
Related
I know few about this and i'm trying to keep building upon it. My goal is to do image stacking with some criteria using C language, as i came upon some cool ideas i think i should be capable of doing with my photos. My C background should be enough to understand what i may need. That being said...
So far i've learned how to read an existing .TIFF file and save it into a char array. The problem is i don't know in which way its data is contained so that i can then be able to analize individual pixels and modify them, or build another .TIFF file from data i previously read.
I've read some things about (a so called) libtiff.h which may be usefull but i can't find where to get it, neither how to install it.
Does anyone know how a .TIFF file data is stored so that i can read it and apply changes to it?
Also,
Does anyone have any experience with handling image files and editing in C? Where did you learn it from?
Do you know of any place i could search for information/tutorials?
Any help will be very usefull,
Thanks in advance.
You can do an enormous amount of very sophisticated processing on TIFFs, or any one of 190+ other formats with ImageMagick without any need to understand TIFF format or write any C. Try searching on Stack Overflow for [imagemagick]
If you want to do processing yourself, consider https://cimg.eu
Another option might be to convert your TIFFs to NetPBM which is much, much simpler to read and write in C. That would be as follows with ImageMagick:
magick INPUT.TIFF -compress none OUTPUT.PPM
I'm new to programming with C, and I need somewhere that I can read up on file compression in C. I only need a simple recognised method. An example would help but mostly somewhere I can read to understand.
maybe a good starting point is RLE which is extremely simple but not so trivial to implement. Check it out: http://en.wikipedia.org/wiki/Run-length_encoding
The first method I learned in school is Huffman Encoding. Here is a link: http://en.wikipedia.org/wiki/Huffman_coding
Here is a link to a C implementation: http://scanftree.com/Data_Structure/huffman-code
I try to compress memory data by using libbz2 library in C program.
Should I use this function of libbz2?:
int BZ2_bzCompress ( bz_stream *strm, int action );
Can anyone show me an example?
Thank you.
http://www.bzip.org/1.0.3/html/util-fns.html
Use BZ2_bzBuffToBuffCompress() and BZ2_bzBuffToBuffDecompress() for simple paired compress/decompress.
This page describes the meaning of the last 3 parms:
http://www.bzip.org/1.0.3/html/low-level.html
I am preparing myself for a lecture exam on security aspects of software development. I would like to know if it is always possible to read the value of a static char array from a binary with hexdump?
If not on what factors does it depend whether I can read the value of it or not with a hexeditor??
thanks,
If you can locate the variable in the memory, you can read it with a hexdump - that's what hexdump programs are for. How easy it is to locate depends on how much information you have about the binary and on what you know about its expected contents.
Assuming C, yes, in the simple case. However, there are methods to obfuscate such variables to limit reverse engineering.
Yes, but only if it is initialized at compile time. You could get more from a core dump or a debugger.
Does anybody know a good C sample that loads bitmaps and handles all the cases: rle, b/w bitmaps, so on?
Code should be cross-platform.
Thanks.
I would suggest using a library like SDL image
If you are looking for a minimal bmp loader this link will give you all you need to know about the BMP format, data structures and sample code without any library dependency to load:
http://paulbourke.net/dataformats/bmp/.
It also contains code to see the loaded BMP in a open gl texture, so pretty much all you need...
Chris Backhouse made a functional little BMP loader (with an eye to using them as OpenGL textures). It's C++, not C, and he admits it's not cross platform. However, it's small and easy to understand, so I thought I'd add the link here:
http://users.ox.ac.uk/~orie1330/bmploader.html
You need some external library to do this (I recommend ImageMagick). The ImageMagick web site also includes documentation and examples.
Check out for OpenCV Library developed by Intel .
If you are tied to the BMP file format, it's pretty simple to look at the header yourself and get the pixels. See this google search. One of the more interesting matches is here. The most counter-intuitive part is that every line of pixels is 4-byte aligned. Also, watch out for compressed BMPs... (My experience is that many third-party tools have trouble with compressed BMPs, so maybe some libraries you encounter will also..)
If you aren't tied to the BMP file format, I recommend libpng. The manual provides some sample code which is pretty clear.
As others suggested you might want to use an external library like SDL. If you want to learn something and do it yourself, see my answer to this very similar question: Getting RGB values for each pixel from a 24bpp Bitmap for conversion to GBA format in C where you'll find C code which prints out each pixel, and have a look at the wikipedia page about bmp files, because it's very good.