// File: tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::SetNPixels(int, int)
void RGBDImage::
SetNPixels(int nx, int ny)
{
  // Resample color channels
  for (int i = RGBD_RED_CHANNEL; i <= RGBD_BLUE_CHANNEL; i++) {
    if (channels.NEntries() <= i) continue;
    if (channels[i]) channels[i]->Resample(nx, ny);
  }

  // Resample other channels (without interpolation)
  for (int i = RGBD_DEPTH_CHANNEL; i < channels.NEntries(); i++) {
    if (channels.NEntries() <= i) continue;
    R3Matrix tmp(R3identity_matrix);
    if (channels[i]) RGBDResampleDepthImage(*(channels[i]), tmp, nx, ny);
  }

  // Update intrinsics 
  double xscale = (nx > 0) ? (double) width / (double) nx : 1;
  double yscale = (ny > 0) ? (double) height / (double) ny : 1;
  this->intrinsics[0][0] /= xscale;
  this->intrinsics[0][2] /= xscale;
  this->intrinsics[1][1] /= yscale;
  this->intrinsics[1][2] /= yscale;

  // Update width and height of image
  this->width = nx;
  this->height = ny;

  // Invalidate opengl
  InvalidateOpenGL();
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movl %esi, 0xac(%rsp)
movl %edx, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x0, 0xa4(%rsp)
cmpl $0x2, 0xa4(%rsp)
jg 0x29bf5
movq 0x40(%rsp), %rdi
addq $0x18, %rdi
callq 0x19e00
cmpl 0xa4(%rsp), %eax
jg 0x29b98
jmp 0x29be2
movq 0x40(%rsp), %rdi
addq $0x18, %rdi
movl 0xa4(%rsp), %esi
callq 0x277c0
cmpq $0x0, (%rax)
je 0x29be0
movq 0x40(%rsp), %rdi
addq $0x18, %rdi
movl 0xa4(%rsp), %esi
callq 0x277c0
movq (%rax), %rdi
movl 0xac(%rsp), %esi
movl 0xa8(%rsp), %edx
xorl %ecx, %ecx
callq 0xbbe00
jmp 0x29be2
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x29b75
movl $0x3, 0xa0(%rsp)
movq 0x40(%rsp), %rdi
movl 0xa0(%rsp), %eax
movl %eax, 0x3c(%rsp)
addq $0x18, %rdi
callq 0x19e00
movl %eax, %ecx
movl 0x3c(%rsp), %eax
cmpl %ecx, %eax
jge 0x29cb4
movq 0x40(%rsp), %rdi
addq $0x18, %rdi
callq 0x19e00
cmpl 0xa0(%rsp), %eax
jg 0x29c40
jmp 0x29c9e
leaq 0x58(%rsp), %rdi
leaq 0x18a94c(%rip), %rsi    # 0x1b4598
callq 0xcc3e0
movq 0x40(%rsp), %rdi
addq $0x18, %rdi
movl 0xa0(%rsp), %esi
callq 0x277c0
cmpq $0x0, (%rax)
je 0x29c9c
movq 0x40(%rsp), %rdi
addq $0x18, %rdi
movl 0xa0(%rsp), %esi
callq 0x277c0
movq (%rax), %rdi
movl 0xac(%rsp), %edx
movl 0xa8(%rsp), %ecx
leaq 0x58(%rsp), %rsi
callq 0x34a10
jmp 0x29c9e
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0x29c00
cmpl $0x0, 0xac(%rsp)
jle 0x29cdd
movq 0x40(%rsp), %rax
cvtsi2sdl 0x28(%rax), %xmm0
cvtsi2sdl 0xac(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x29ced
movsd 0x13c34b(%rip), %xmm0   # 0x166030
movsd %xmm0, 0x30(%rsp)
jmp 0x29ced
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
cmpl $0x0, 0xa8(%rsp)
jle 0x29d22
movq 0x40(%rsp), %rax
cvtsi2sdl 0x2c(%rax), %xmm0
cvtsi2sdl 0xa8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0x29d32
movsd 0x13c306(%rip), %xmm0   # 0x166030
movsd %xmm0, 0x28(%rsp)
jmp 0x29d32
movq 0x40(%rsp), %rdi
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
addq $0x140, %rdi            # imm = 0x140
xorl %esi, %esi
callq 0x226f0
movsd 0x8(%rsp), %xmm1
movq 0x40(%rsp), %rdi
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0x140, %rdi            # imm = 0x140
xorl %esi, %esi
callq 0x226f0
movsd 0x10(%rsp), %xmm1
movq 0x40(%rsp), %rdi
movsd 0x10(%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rax)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
addq $0x140, %rdi            # imm = 0x140
movl $0x1, %esi
callq 0x226f0
movsd 0x18(%rsp), %xmm1
movq 0x40(%rsp), %rdi
movsd 0x8(%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0x140, %rdi            # imm = 0x140
movl $0x1, %esi
callq 0x226f0
movsd 0x20(%rsp), %xmm1
movq 0x40(%rsp), %rdi
movsd 0x10(%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rax)
movl 0xac(%rsp), %eax
movl %eax, 0x28(%rdi)
movl 0xa8(%rsp), %eax
movl %eax, 0x2c(%rdi)
movq (%rdi), %rax
callq *0x1c8(%rax)
addq $0xb8, %rsp
retq
nopl (%rax,%rax)