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