how to get stream from an Image in c - c

Is there anyway in C to get an image, stream by stream and how can I understand how many stream there are in an Image?
the Image is in JPEEG type.
and for saving this stream in another file I'll have any problem?

You can have a look to the free OpenCV library : http://opencv.org/
Here there is a tutorial with some examples : http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/
It's largely used for this kind of treatments.

Without using any external library what you have as a jpeg image is simply a binary file. You may do whatever with it via fopen(), fscanf() or any other file functions.
for saving this stream in another file I'll have any problem?
No problem if you are just coping a jpeg image to another new file. But problem may be there if you change the image extension. Please have a look at here

Related

sdl ttf windows-1250 encoding

In file text.txt I have this sentenc:
"Příliš žluťoučký kůň úpěl ďábelské ódy."
(I think Windows uses Windows-1250 code page to represent this text.)
In my program I save it to a buffer
char string[1000]
and render string with ttf to SDL_Surface *surface
surface = TTF_RenderText_Blended(font, string, color);
/*(font is true type and support this text)*/
But it gives me not correct result:
I need some reputation points to post images
so I can only describe that ř,í,š,ž,ť,ů,ň,ď are not displayed correctly.
Is it possible to use ttf for rendering this sentence correctly?
(I tried also TTF_RenderUTF8_Blended, TTF_RenderUNICODE_Solid... with worse result.)
The docs for TTF_RenderText_Blended say that it takes a Latin-1 string (Windows-1252) - this will be why it isn't working.
You'll need to convert your input text to UTF-8 and use RenderUTF8, or to UTF-16 and use RenderUNICODE to ensure it is interpreted correctly.
How you do this depends on what platform your app is targeted to - if it is Windows, then the easiest way would be to use the MultiByteToWideChar Win32 API to convert it to UTF-16 and then use the TTF_RenderUNICODE_Blended to draw it.
My solution will be this:
Three input files. In first file there will be a set of symbols from czech alphabet.
Second file will be sprite bitmap file where graphic symbols will be sorted in the
same order as in first file. In my program symbols from third input file will be compared with symbols from first file and right section of sprite will be copied on sreen one by one.
I will leave out sdl_ttf. It has some advantages and disadvantages but I think it will work for my purposes.
Thanks for all responses

Gstreamer audio input to mp3

I am trying to create a simple program using Gstreamer to take the input from a microphone and save it to a mp3 file. I keep getting
Internal data flow error
and can´t seem to find the problem(I am new to Gstreamer).
Here is a link to my code:
http://pastebin.com/QDexe8Fz
Your code is not handling return codes from the functions. As a result your in the dark when it fails. Anyway in your code you forgot to link the elements. Right after line 70, also do gst_element_link_many(....);
Traditionally, the GStreamer package doesn't include support for MP3. However, you can go after codecs and plugins to make it support.

Audio file format that can be written without seeking

I want to write audio data to stdout, preferably using libsndfile. When I output WAV to /dev/stdout I manage to write the header, but then I get an error
Error : could not open file : /dev/stdout
System error : Illegal seek.
I assume this is related to http://www.mega-nerd.com/libsndfile/FAQ.html#Q017, some file formats cannot be written without seeks. However, when I try to output SF_FORMAT_AU | SF_FORMAT_PCM_16 instead, I still get the same Illegal seek error.
Are there any audio file formats that can be written completely without seeking?
I'm using Linux.
EDIT: It might be obvious, but RAW format works (without seeking). Unfortunately I need a format that has meta information like sample rate.
You should finish reading that FAQ... the link you give us has all the answers.
However, there is at least one file format (AU) which is specifically designed to be written to a pipe.
So use AU instead of WAV.
Also make sure that you open the SNDFILE object with sf_open_fd, and not sf_open_virtual (or sf_open):
SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo,
void *user_data) ;
If you use sf_open_fd, then libsndfile will use fstat to determine whether the file descriptor is a pipe or a regular file. If you use sf_open_virtual or sf_open, it will assume that the file is seekable. This appears to be a flaw in libsndfile, but you should be using sf_open_fd anyway.
Footnote: Don't open /dev/stdout to get standard output; it is already open and there is no need to open it again. Use file descriptor STDOUT_FILENO.
Ended outputting an "infinite" wav header, and then writing raw PCM data for as long as the audio lasts. Not really valid, but most players seem to understand anyway.
The wav header is here, in case anyone wants it: https://gist.github.com/1428176
You could write to a temp file (perhaps in /tmp), let the libsnd seek to modify the .wav(RIFF) header of the temp file, and then, after libsnd has closed the file, stream the temp file out to stdout.

fetching waveform for visualization in c on any music files format (mp3/ogg/etc..)

I would like to know how can i fetch the a waveform from any music file format in order to visualize it using some kind of gui. i would like to use already written libraries instead of writing my own.
any ideas?
thanks!
And for a library to do what you ask, check out libsndfile.
That depends on the music file format. LameLib can be used for decoding mp3s, and libogg can be used for decoding oggs. Uncompressed wav files don't need to be decoded, since the file stores the raw PCM data; you just need to read in the file headers, and there's lots of sample code out there that shows you how to do that.
If a program that lets you visualize an audio waveform would help, try Audacity.

Imagettftext like C function

I need to implement a functionality similar to PHP's imagettftext function. I need to enter a text and output a bmp image based on that. I already looked at freetype but it converts character by character and is not suitable to convert the whole text to an image. I am stuck at the moment. How can I access the source code of imagettftext function or is there another library inc to do that?
OK. I solved the question. In GD library there is a function to do (but requires FreeType) that and then you can save the image in PNG format.

Resources