//--------Delivers BMP Image---------// void serveBMP (int socket, char request[]) { int row = -SIZE/2; //Defines where each row should start int col = -SIZE/2; //Defines where first column should start int iterations = 0; //Count the amount of iterations needed //to escape the set complex current; //The current coodinates of the point //being tested int colCounter = 0; //Current collum int rowCounter = 0; //Current row int zoom = 0; //The zoom level of the image double xMiddle = 0; //The x (real) component of the //center of the image double yMiddle = 0; //The y (imaginary) component of the //center of the image bits8 byte = 0; //Intensity of color from each sub-pixel writeHTTPHeader(socket); writeBMPHeader(socket); //get coordinates from URL sscanf (request, "GET /tile_x%lf_y%lf_z%d.bmp", &xMiddle,&yMiddle,&zoom); //print each pixel out while (rowCounter < SIZE){ current.y = yMiddle + row*exp2(-1*zoom) + exp2(-1*zoom)/2; while (colCounter < SIZE){ current.x = xMiddle + col*exp2(-1*zoom) + exp2(-1*zoom)/2; iterations = escapeSteps(current.x,current.y); writePixel (socket,iterations, byte); col++; colCounter++; } col = -SIZE/2; colCounter = 0; row++; rowCounter++; } }
void writeBMP(ByteStream& stream, iw_image* image) { writeBMPHeader(stream, image->width, image->height); for (int y = image->height - 1; y >= 0; --y) { for (int x = 0; x < image->width; ++x) { //stream.put(image->b(x, y)); //stream.put(image->g(x, y)); //stream.put(image->r(x, y)); //stream.put(image->a(x, y)); //stream.write(convertIntToByteArrayLE(image->argb(x, y))); stream.put(image->pixels[y * image->bpr + x * 4 + 2]); stream.put(image->pixels[y * image->bpr + x * 4 + 1]); stream.put(image->pixels[y * image->bpr + x * 4 + 0]); stream.put(image->pixels[y * image->bpr + x * 4 + 3]); } } }