save bmp
This commit is contained in:
parent
bcdea67e9a
commit
02e42d5efd
1 changed files with 10 additions and 7 deletions
13
mandelbrot.c
13
mandelbrot.c
|
@ -18,17 +18,13 @@ int main(int argc, char *argv[]) {
|
|||
int y = i / screen->w;
|
||||
int x = i % screen->w;
|
||||
|
||||
if (x == 0) {
|
||||
printf("y = %d\n", y);
|
||||
}
|
||||
|
||||
float complex c = ((3.0 * x / screen->w) - 2.0)
|
||||
+ I * ((2.0 * y / screen->h) - 1.0);
|
||||
|
||||
bool diverges = false;
|
||||
float complex z = 0;
|
||||
int it;
|
||||
for (it=1; it<256; it++) {
|
||||
for (it = 1; it < 256; it++) {
|
||||
z = cpowf(z, 2) + c;
|
||||
if (cabs(z) > 100) {
|
||||
diverges = true;
|
||||
|
@ -47,6 +43,13 @@ int main(int argc, char *argv[]) {
|
|||
if (y % 10 == 0)
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
|
||||
/* Save BMP */
|
||||
char *file = "mandelbrot.bmp";
|
||||
if (SDL_SaveBMP(screen, file) != 0) {
|
||||
fprintf(stderr, "Could not write %s!\n", file);
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(screen)) {
|
||||
SDL_UnlockSurface(screen);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue