How to write a C Program to BUILDS A STRING FROM THE LSB BITS OF EACH PIXEL in C Programming Language ?
This C Program BUILDS A STRING FROM THE LSB BITS OF EACH PIXEL.
Solution:
- // Revelation core, returns a message with the secret content of the image
- // SINGLE CHANNEL (R), SINGLE BIT PER CHANNEL, NO MAGIC NUMBER.
- // SIMPLY BUILDS A STRING FROM THE LSB BITS OF EACH PIXEL.
- message reveal(const char *img){
- int i,j;
- RGBQUAD pixel;
- FIBITMAP *image1= open_image(TESTIMAGE);
- unsigned w,h;
- int end = 0; //use as flag when found magic number, if not updated we reveal all the pixels
- w = FreeImage_GetWidth(image1);
- h = FreeImage_GetHeight(image1);
- int len = (h*w/8);
- message m; // message is struct{ char chars[]; }
- m.chars= (char*)malloc(sizeof(char)*len);
- char bits[h*w];
- couple indexes;
- unsigned char tmp;
- int n = 0, b=0;
- for (i=0; i<h; i++){
- for (j=0; j<w; j++){
- if(b%8==0)b=0;
- indexes = mindex_direct(n,w,h); //returns couple (x,y) of n-th pixel in Direct order
- if(readBit(image1,indexes,0))
- m.chars[n/8] = set_bit(m.chars[n/8],7-b);
- else
- m.chars[n/8] = unset_bit(m.chars[n/8],7-b);
- n++;
- b++;
- }
- }
- }
Learn More :
String
- Write a c program to check given string is palindrome number or not.
- C Program to Convert Text String to Binary
- C Program String - Alphabet Count Example
- C Program String Example
- C Program String Count Example
- C Program String Example
- C Program to Print a String Without Use Semicolon.
- C Program To Find Length Of A String Including Blank Spaces, Tabs, And Other Special Characters
- C Program To Find Length Of String And Concatenate Two Strings
- C Program To Find The Length, Reverse Of A String And To Check It Is Palindrome or Not
- C Program To Print String In Formatted Output Form
- C Program To Reverse The String Using Pointer
- C Program Concatenating Two Strings Into A Third System
- C Program Date from string DDDD-DD-DD
- C Program Finds Sub-String Search in String
- C Program to concatenate two strings without using string functions
- C Program to Count Vowels, Consonants and Spaces in a string
- C Program to convert a string to upper case
- C Program Performs a search and replace for a specified target and replacement string
- C Program Anagrams
- C Program to find string length without library function
- C Program to Check Given String is Palindrome or Not
- C Program to Converts a Number to a String.
- Design a C function that shortens a string to 8 characters
Pixel