Solved

Crearting human readable image in C

Posted on 2004-08-26
12
376 Views
Last Modified: 2010-04-15
Dear All,

    I would like to develop a C program which should do the following things.

  1.  The given text should be displayed in human readable format ......

         For example: Whenever  we create user account in some server(like yahoo mail server) they will provide a human readable image.

  Let me know if anybody have idea how to do this.

Thanks & Regards,
Priyashree
0
Comment
Question by:priyashree
  • 6
  • 4
12 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11902643
Have to be in pure C? Which Operating system? Images are highly system dependent if you want to make it in an easy way.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11902661
By example, in Windows OS you can choose an ugly font (.TTF), paint over a bitmap and draw some random vertical lines on (like a bar code).
0
 

Author Comment

by:priyashree
ID: 11902696
yes of course the program should be purely in C and the platform is linux......
is it possible
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11902850
Well, now you have to choose a graphics format and then a graphics library to generate it. How do you will present your bitmap, in a Web page, in a window, no need to display?
0
 

Author Comment

by:priyashree
ID: 11903488
i going to display it in a webpage
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11904340
OK, I guess GIF format will be the best suited for your OS/Language.
Take a look to this uncompressed GIF library:
http://sourceforge.net/projects/libungif/
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11904396
Also you can use GD library, it is very popular in unix/web environment:
http://www.boutell.com/gd/
0
 

Author Comment

by:priyashree
ID: 11911496
if you don't mind can u give me one sample program

thanks a lot
0
 

Author Comment

by:priyashree
ID: 11940289
Dear jaime_olivers,

   I got one solution for the problem i have posted in this thread. Kindly walk through the code and give me your suggestions.

 Now i want to store the entire image in database in form of bytes....

  I am working with that..........

  Thanks for your support in this regard...........

  How to insert some filters to this image

  /* File : gd-eg1.c */
#include <gd.h>
#include <stdio.h>
#include <gdfontl.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
char *generateRandomText(); //forward declaration
int main() {
      gdImagePtr im; //declaration of the image
      FILE *out; //output file
      int black,white;
        char *s = "Welcome";
       im = gdImageCreate(100,100); //create an image, 100 by 100 pixels
      black = gdImageColorAllocate(im, 0, 0, 0); //allocate black color
      white = gdImageColorAllocate(im, 255, 255, 255);      //allocate white color      
        gdImageString(im, gdFontLarge,      100 / 2 - (strlen(s) * gdFontLarge->w / 2),      100 / 2 - gdFontLarge->h / 2,      generateRandomText(), white);        
        out = fopen("test1.jpg", "w"); //open a file
            gdImageJpeg(im, out, -1); //write the image to thefile using the default quality setting
      /* be good, clean up stuff */
      fclose(out);
      gdImageDestroy(im);
}
char* generateRandomText() // To generate text in random order
   {
 
       unsigned int x,seed;
       char *k;
       int i,mix;
       int len;
       k = (char *) malloc (8 *sizeof(char));
       seed = (unsigned int) time(NULL);
       srand(seed);
       for( i = 0;   i < 8;i++ ) {
         mix= rand()%2;
         if (mix==0)
           k[i]= rand()%26 +'a';
         else
           k[i]= rand()%26 +'A';
       }
       printf("k is %s\n\n",k);
       len = strlen(k);
       printf("the length of s is %d \n\n" ,len);
       return k;
   }

Regards,
Priya.M



0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 60 total points
ID: 11940361
Hi, about your hidden text, you can do something like this:
http://www.micrologicaperu.com/imagenes/sample.html
by simply drawing lines of different colors.

To insert data into your database, that will depend on your specific database implementation.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Read file descriptor 3 in C 14 112
Socket Programming (Unix) 8 140
Fill Null values 5 28
How to increment counter variables in ANSI  C (Not C# or C++). 9 17
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question