 
 // Given "bitmap", this returns the pixel of bitmap at the point ("x", "y").
 __host__ __device__
-Pixel* pixel_at(Bitmap* bitmap, int x, int y) {
-  return bitmap->pixels + bitmap->width * y + x;
+Pixel* pixel_at(const Bitmap& bitmap, int x, int y) {
+  return bitmap.pixels + bitmap.width * y + x;
 }
 
 /* Write "bitmap" to a PNG file specified by "path"; returns 0 on

  Bitmap bitmap;
  bitmap.width = width;
  bitmap.height = height;
  cudaMalloc(&bitmap.pixels, sizeof(Pixel) * bitmap.width * bitmap.height);

  Bitmap* devBitmap;
  cudaMalloc(&devBitmap, sizeof(Bitmap));
  cudaMemcpy(devBitmap, &bitmap, sizeof(Bitmap), cudaMemcpyHostToDevice);

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

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

  cudaDeviceSynchronize();

  Pixel* devicePixels = bitmap.pixels;
  bitmap.pixels = new Pixel[bitmap.width * bitmap.height];
  cudaMemcpy(bitmap.pixels, devicePixels, sizeof(Pixel) * bitmap.width * bitmap.height, cudaMemcpyDeviceToHost);

  save_png_to_file(&bitmap, filename);

  cudaFree(devicePixels);
  cudaFree(devBitmap);

  delete[] bitmap.pixels;

  cudaError error = cudaGetLastError();

}

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

