// File: tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::ReadColorChannels()
int RGBDImage::
ReadColorChannels(void)
{
  // Check if already resident
  if (color_resident_count > 0) {
    color_resident_count++;
    return 1;
  }

  // Initialize image
  R2Image color_image(width, height, 3);

  // Check filename
  if (color_filename) {
    // Get full filename
    char full_filename[4096];
    const char *dirname = (configuration) ? configuration->ColorDirectory() : NULL;
    if (dirname) sprintf(full_filename, "%s/%s", dirname, color_filename);
    else sprintf(full_filename, "%s", color_filename);

    // Read color image
    if (!color_image.Read(full_filename)) return 0;

    // Resize color image if necessary
    if ((width > 0) && (height > 0) &&
        ((width != color_image.Width()) || (height != color_image.Height()))) {
      R3Matrix tmp(R3identity_matrix);
      RGBDResampleColorImage(color_image, tmp, width, height);
    }
  }

  // Create color channels
  return CreateColorChannels(color_image);
}

// Assembly:
subq $0x10b8, %rsp           # imm = 0x10B8
movq %rdi, 0x10a8(%rsp)
movq 0x10a8(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x1f8(%rax)
jle 0x2d4a9
movq 0x28(%rsp), %rax
movl 0x1f8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1f8(%rax)
movl $0x1, 0x10b4(%rsp)
jmp 0x2d6bb
movq 0x28(%rsp), %rax
movl 0x28(%rax), %esi
movl 0x2c(%rax), %edx
leaq 0x1090(%rsp), %rdi
movl $0x3, %ecx
callq 0xd1c40
movq 0x28(%rsp), %rax
cmpq $0x0, 0x1d8(%rax)
je 0x2d67e
movq 0x28(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2d506
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x30720
movq %rax, 0x20(%rsp)
jmp 0x2d4fa
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x2d50f
xorl %eax, %eax
movq %rax, 0x18(%rsp)
jmp 0x2d50f
movq 0x18(%rsp), %rax
movq %rax, 0x88(%rsp)
cmpq $0x0, 0x88(%rsp)
je 0x2d576
movq 0x28(%rsp), %rax
leaq 0x90(%rsp), %rdi
movq 0x88(%rsp), %rdx
movq 0x1d8(%rax), %rcx
leaq 0x139a19(%rip), %rsi    # 0x166f63
movb $0x0, %al
callq 0x12130
jmp 0x2d598
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
leaq 0x1090(%rsp), %rdi
callq 0xd2160
jmp 0x2d6ca
movq 0x28(%rsp), %rax
leaq 0x90(%rsp), %rdi
movq 0x1d8(%rax), %rdx
leaq 0x13bb7a(%rip), %rsi    # 0x16910b
movb $0x0, %al
callq 0x12130
leaq 0x1090(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x27f50
movl %eax, 0x14(%rsp)
jmp 0x2d5b3
movl 0x14(%rsp), %eax
cmpl $0x0, %eax
jne 0x2d5d4
movl $0x0, 0x10b4(%rsp)
movl $0x1, 0x78(%rsp)
jmp 0x2d6ae
movq 0x28(%rsp), %rax
cmpl $0x0, 0x28(%rax)
jle 0x2d67c
movq 0x28(%rsp), %rax
cmpl $0x0, 0x2c(%rax)
jle 0x2d67c
movq 0x28(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0xc(%rsp)
leaq 0x1090(%rsp), %rdi
callq 0x22940
movl %eax, 0x10(%rsp)
jmp 0x2d611
movl 0xc(%rsp), %eax
movl 0x10(%rsp), %ecx
cmpl %ecx, %eax
jne 0x2d648
movq 0x28(%rsp), %rax
movl 0x2c(%rax), %eax
movl %eax, 0x4(%rsp)
leaq 0x1090(%rsp), %rdi
callq 0x22950
movl %eax, 0x8(%rsp)
jmp 0x2d63c
movl 0x4(%rsp), %eax
movl 0x8(%rsp), %ecx
cmpl %ecx, %eax
je 0x2d67c
leaq 0x186f49(%rip), %rsi    # 0x1b4598
leaq 0x30(%rsp), %rdi
callq 0xcc3e0
jmp 0x2d65b
movq 0x28(%rsp), %rax
movl 0x28(%rax), %edx
movl 0x2c(%rax), %ecx
leaq 0x1090(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x35150
jmp 0x2d67a
jmp 0x2d67c
jmp 0x2d67e
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
movq 0x178(%rax), %rax
leaq 0x1090(%rsp), %rsi
callq *%rax
movl %eax, (%rsp)
jmp 0x2d69c
movl (%rsp), %eax
movl %eax, 0x10b4(%rsp)
movl $0x1, 0x78(%rsp)
leaq 0x1090(%rsp), %rdi
callq 0xd2160
movl 0x10b4(%rsp), %eax
addq $0x10b8, %rsp           # imm = 0x10B8
retq
movq 0x80(%rsp), %rdi
callq 0x12c20
nopw (%rax,%rax)