 }
 
 __global__
-void calc(Bitmap* bitmap) {
+void calc(Bitmap bitmap) {
   // int index = blockIdx.x * blockDim.x + threadIdx.x;
   // int stride = gridDim.x * blockDim.x;
 

  complex<double> t;
  int iter;
  Pixel* pixel;
  int width = bitmap->width;
  int height = bitmap->height;
  for (y = blockIdx.y * blockDim.y + threadIdx.y; y < height; y += yStride) {
    for (x = blockIdx.x * blockDim.x + threadIdx.x; x < width; x += xStride) {
      t = complex<double>(lowerX + (upperX - lowerX) * x / (width - 1),

  Bitmap bitmap;
  bitmap.width = width;
  bitmap.height = height;

  size_t pixelsCount = bitmap.width * bitmap.height;
  size_t pixelsSize = pixelsCount * sizeof(Pixel);
  cudaMalloc(&bitmap.pixels, pixelsSize);

  dim3 threadsPerBlock(16, 16);
  dim3 numBlocks((bitmap.width + threadsPerBlock.x - 1) / threadsPerBlock.x,
                 (bitmap.height + threadsPerBlock.y - 1) / threadsPerBlock.y);

  calc<<<numBlocks, threadsPerBlock>>>(bitmap);

  cudaDeviceSynchronize();

  Pixel* devicePixels = bitmap.pixels;
  bitmap.pixels = new Pixel[pixelsCount];
  cudaMemcpy(bitmap.pixels, devicePixels, pixelsSize, cudaMemcpyDeviceToHost);

  save_png_to_file(&bitmap, filename);

  cudaFree(devicePixels);
  delete[] bitmap.pixels;

  cudaError error = cudaGetLastError();
