Witam

Mecze sie juz dlugi czas z tym zadaniem. Moze ktos mi powiedziec czemu to mi rysuje biala bitmape? Format zapisu stalopozycyjnego to 16.16

 #include <stdio.h>
#include <stdlib.h>
#define MUL(x,y) ((((x)>>4)*((y)>>4))>>8)
#define DIV(x,y)  (((x)<<8)/((y)<<8))
#define FixedToDouble(x) ((double)x/(double)(1<<16))

unsigned short fun(int cX, int cY)
{
            unsigned short iter = 0;
int zx,zy,tmp;
zx=0;
zy=0;
            

     do       {
				tmp = MUL (zx,zx) - MUL (zy,zy) + cX;
			   zy=((MUL(zx,zy))<<1)+cY;
                zx = tmp;
                iter++;
				
            } while ( (MUL(zx,zx)+MUL(zy,zy))<((4)<<16) && (iter<255)) ;
	return iter;
}
int main()
{
	
    FILE *fp;
    unsigned char header[54] = {66, 77, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0,
    40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    unsigned long image_width, image_height, image_size, total_size;
    unsigned char pads, r, g, b;
    unsigned short iter;
    int zx, zy, cX, cY, tmp;
    image_width = 600;
    image_height = 600;
    pads = ((image_width * 3) % 4 == 0) ? 0 : 4 - (image_width * 3) % 4;
    image_size =  (image_width * image_height) * 3 + image_width * pads;
    total_size = image_size + 54;
    header[2] = (total_size >> 0) & 255;
    header[3] = (total_size >> 8) & 255;
    header[4] = (total_size >> 16) & 255;
    header[5] = (total_size >> 24) & 255;
    header[18] = (image_width >> 0) & 255;
    header[19] = (image_width >> 8) & 255;
    header[20] = (image_width >> 16) & 255;
    header[21] = (image_width >> 24) & 255;
    header[22] = (image_height >> 0) & 255;
    header[23] = (image_height >> 8) & 255;
    header[24] = (image_height >> 16) & 255;
    header[25] = (image_height >> 24) & 255;
    header[34] = (image_size >> 0) & 255;
    header[35] = (image_size >> 8) & 255;
    header[36] = (image_size >> 16) & 255;
    header[37] = (image_size >> 24) & 255;
    fp = fopen("out.bmp","wb");
    if (fp == NULL)
    {
        perror(NULL);
        return 1;
    }
	int normalizer=(150)<<16;
    fwrite(header, 1, 54, fp);
    for (int i = 0; i < image_height; i++)
    {
        for (int j = 0; j < image_width; j++)
        {
            zx = zy = 0;
			cX = DIV((( ((j)<<16) - ((image_width)<<15))<<8),normalizer);
			cY = (( ((i)<<16) - ((image_height)<<15))<<8)/((normalizer)<<8);

		iter = fun (cX,cY);
		printf("%d, %f, %f\n", iter, FixedToDouble(cX), FixedToDouble(cY));
            r = iter | (iter << 1);
            g = iter | (iter << 3);
            b = iter | (iter << 5);
            putc(b, fp);
            putc(g, fp);
            putc(r, fp);
        }
        for (int k = 0; k < pads; k++)
        {
            putc(0, fp);
        }
    }
    fclose(fp);
    return 0;
}