I am doing a project on steganography ( I hope you know what it is :) ) I have to convert a text file (if possible a RTF File) to an image file like jpg or gif etc. But I do not seem to get around this problem and I'm stuck in it.
Please can anybody help me with this? :-/

A simple screen capture would do the trick.
Alt-print screen, paste into your image editor to remove extraneous bits.

A simple screen capture would do the trick.
Alt-print screen, paste into your image editor to remove extraneous bits.

Sorry But I have to do this with the help of a C or C++ Program

Till now I have been able to come up with this code:

#include <windows.h>
#include <windowsx.h>
#include <vicdefs.h>
#include <string.h>


int text_to_image(char far *fname, imgdes *resimg)
{
#define FONT_SIZE 12
   static LOGFONT lf = { // Use font described by LOGFONT struct
      0, 0, 0, 0, FW_NORMAL, 0, 0, 0,
      ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
      DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "ARIAL"
      };
   HFONT hFont, hOldFont;
   HBITMAP hOldBitmap;
   HWND hWnd;
   HDC hDC, hMemDC;
   RECT rc;
   imgdes tmptext;
   int rcode = NO_ERROR, captionHt, captionWd;
   char *caption; 

   HANDLE fhandle;
   DWORD filesize, dwBytsRd;

   fhandle = CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
   filesize = SetFilePointer(fhandle, 0L, NULL, FILE_END);
   SetFilePointer(fhandle, 0L, NULL, FILE_BEGIN);
   filesize++;
   if((caption = (UCHAR near *)calloc(filesize,1)) == NULL)
      return(BAD_MEM);  // If area not allocated

   // Read the file
   ReadFile(fhandle, (LPSTR)caption, (unsigned)filesize, &dwBytsRd, NULL);
   CloseHandle(fhandle);

   hDC = GetDC(GetActiveWindow());
   hMemDC = CreateCompatibleDC(hDC);

   // Set the font point size
   lf.lfHeight= - MulDiv(FONT_SIZE, GetDeviceCaps(hDC,LOGPIXELSY), 72);

   //Set lfEscapement and lfOrientation to 10 * angle to rotate text
   //for example, to rotate 45 degrees set the values to 450

   hFont = CreateFontIndirect(&lf); // Create our font
   SetBkMode(hMemDC, TRANSPARENT);
   hOldFont = SelectObject(hMemDC, hFont); // Select font into DC
   // Don't write any text, just fill rc with text dimensions
   DrawText(hMemDC, caption, -1, &rc, DT_CALCRECT | DT_LEFT | DT_EXPANDTABS | DT_NOPREFIX); 

   // Calculate the text size and create temp image 
   captionHt = rc.bottom - rc.top + 1;
   captionWd = rc.right - rc.left + 1;
   rcode = allocimage(&tmptext, captionWd, captionHt, 1);
   zeroimage(255, &tmptext); // Create a white background
   // Select bitmap into the memory DC
   hOldBitmap = SelectObject(hMemDC, tmptext.hBitmap);
   // Set the rect for adding the text
   SetRect(&rc, 0, 0, tmptext.endx, tmptext.endy);

   // Write the text 
   DrawText(hMemDC, caption, -1, &rc, DT_LEFT | DT_EXPANDTABS | DT_NOPREFIX);

   // Restore the original bitmap and font and delete the new font
   SelectObject(hMemDC, hOldBitmap);
   DeleteObject(SelectObject(hMemDC, hOldFont));
   DeleteDC(hMemDC);         // Delete memory DC
   ReleaseDC(hWnd, hDC);
   free(caption);

   freeimage(resimg);
   copyimgdes(&tmptext, resimg);
   return(rcode);
}

But its showing some errors.
error C2440: '=' : cannot convert from 'unsigned char *' to 'char *'
error C2440: '=' : cannot convert from 'void *' to 'struct HFONT__ *
error C2440: '=' : cannot convert from 'void *' to 'struct HBITMAP__ *'

> I have to convert a text file (if possible a RTF File) to an image file like jpg or gif etc.
Except this isn't steganography.

Steganography takes an existing image, and "hides" a text file inside it.

This article has been dead for over six months. Start a new discussion instead.