Translating Protocols

You should be able to draw Windows bmp files on the printer. The format for .bmp files is described below. You will write a Lua program to read the .BMP file and the program will write a postscript file which will draw the [url removed, login to view] .BMP file formatActually there are several different .BMP file formats, but the one I describe is the Monochrome bitmap format. It can only store pictures in two colors, usually black and white, since my laser printer can only print in black and I usually print on white paper..BMP files tend to be fairly large. They aren't a particularly efficient way to store pictures, although they are going to compare very favorably with the Postscript files you generate for this [url removed, login to view] order to save storage space, the authors of the .BMP format gave up easy human readability. Here is a description of the first few bytes of the file, disguised as a C struct declaration.

#pragma pack(1)struct BMP_header {  char id[2]; /* this always contains the two characters 'B' and 'M'*/  int fileSize;/* total size of file */  int filler;  /* "reserved" -- usually zero */  int startOfData; /* byte number (starting from zero) of file where actual*/ /* bitmap starts */  int headerSize; /* believed to be always 40 */  int width; /* number of pixels in each row */  int height; /* number of rows of pixels */  short planes; /* number of "planes" -- believed to be always 1 */  short bitsPerPixel; /* number of bits per pixel.  1 for monochrome format. */ /* other possible values include 4, 8, 16, 24, and 32. */ /* But I don't describe variations in the rest of the file */ /* which may occur for other values of bitsPerlPixel than 1 */  int compression; /* I believe this value is always 1 for monochrome format*/  int bitMapSize; /* length of bitmap data in bytes  /* I think = (width * height * bitsPerPixel)/8 */  int hresolution; /* seems to be zero */  int vresolution; /* seems to be zero */  int colors; /* seems to be zero */  int importantColors; /* seems to be zero */  unsigned char palette[2][4]; /* There are two colors in the palette array (for mono- */ /* chrome .BMP files)  */                /*black is represented in the palette by the bytes 0,0,0,0 */ /*white by the bytes 255,255,255,0 */};The bitmap data follows, 8 bits per byte, row at a time, until all rows have appeared. If a bit is a zero, the color described by palette[0] is displayed; if a bit is a one, the color described by palette[1] is displayed. In the files I looked at, white was a one bit, and black was a zero bit.[I got this information from the Web, although I retyped it as a header file myself. A google search will reveal dozens of pages talking about .BMP files, and several conversion programs. Nobody will convert them the way I expect you to do it.]You'll want to turn this header declaration into Lua code, by reading the first two bytes as a string, the next four as an integer, etc. (See the sample code below.)TO read a binary file in Lua, you should specify "rb" in the mode argument of the [url removed, login to view](). Otherwise, Lua will try to treat spaces and newline characters specially, which will completely mess up your input if the binary pattern for those characters happens to appear by [url removed, login to view] than that, you can read a binary file byte by byte, just like an ASCII file. However, to make any sense of the file, you'll want to read it into a string, and use [url removed, login to view] to look at it.

IMPORTANT: Lua programming and ghost script programming skills are REQUIRED of the freelancer.

Please view the project clarification board for the attachments.

Skills: Windows Desktop

See more: write skills freelancer, write program binary search, windows store freelancer, width first search, white board freelancer, store freelancer, unsigned integer, unsigned bits, struct programming, storage freelancer, starting web programming, space freelancer, search string array, search rb, search binary, save freelancer, programming lua, print pack, print attachments, planes freelancer, pattern string, order binary search, open pages freelancer, one bits, m string

About the Employer:
( 0 reviews ) Chennai, India

Project ID: #1257951

1 freelancer is bidding on average $30 for this job


do you knew Google desktop ?

$30 USD in 1 day
(0 Reviews)