// File: tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::ReadColorChannels()
int RGBDSurface::
ReadColorChannels(void)
{
  // Initialize image
  R2Image rgb_image(width, height);

  // Check filename
  if (texture_filename) {
    // Get full filename
    char full_filename[4096];
    const char *dirname = (configuration) ? configuration->TextureDirectory() : NULL;
    if (dirname) sprintf(full_filename, "%s/%s", dirname, texture_filename);
    else sprintf(full_filename, "%s", texture_filename);
    if (!RNFileExists(full_filename)) return 0;
  
    // Read color image
    if (!rgb_image.Read(full_filename)) return 0;

    // Check image dimensions
    if ((rgb_image.Width() != width) || (rgb_image.Height() != height)) {
      RNFail("Mismatching image dimensions (%d,%d) vs (%d,%d) in %s\n",
        rgb_image.Width(), rgb_image.Height(), width, height, texture_filename);
      // return 0;
    }
  }

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

// Assembly:
subq $0x1078, %rsp           # imm = 0x1078
movq %rdi, 0x1068(%rsp)
movq 0x1068(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x28(%rax), %esi
movl 0x2c(%rax), %edx
leaq 0x1050(%rsp), %rdi
movl $0x3, %ecx
callq 0xd1c40
movq 0x30(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x26469
movq 0x30(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x262f1
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x19f60
movq %rax, 0x28(%rsp)
jmp 0x262e5
movq 0x28(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x262fa
xorl %eax, %eax
movq %rax, 0x20(%rsp)
jmp 0x262fa
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x2634f
movq 0x30(%rsp), %rax
leaq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rdx
movq 0x38(%rax), %rcx
leaq 0x140c3d(%rip), %rsi    # 0x166f63
movb $0x0, %al
callq 0x12130
jmp 0x2636b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
leaq 0x1050(%rsp), %rdi
callq 0xd2160
jmp 0x264b7
movq 0x30(%rsp), %rax
leaq 0x50(%rsp), %rdi
movq 0x38(%rax), %rdx
leaq 0x142da7(%rip), %rsi    # 0x16910b
movb $0x0, %al
callq 0x12130
leaq 0x50(%rsp), %rdi
callq 0xde770
movl %eax, 0x1c(%rsp)
jmp 0x2637b
movl 0x1c(%rsp), %eax
cmpl $0x0, %eax
jne 0x2639c
movl $0x0, 0x1074(%rsp)
movl $0x1, 0x38(%rsp)
jmp 0x2649b
leaq 0x1050(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x27f50
movl %eax, 0x18(%rsp)
jmp 0x263b4
movl 0x18(%rsp), %eax
cmpl $0x0, %eax
jne 0x263d5
movl $0x0, 0x1074(%rsp)
movl $0x1, 0x38(%rsp)
jmp 0x2649b
leaq 0x1050(%rsp), %rdi
callq 0x22940
movl %eax, 0x14(%rsp)
jmp 0x263e8
movl 0x14(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x26417
leaq 0x1050(%rsp), %rdi
callq 0x22950
movl %eax, 0x10(%rsp)
jmp 0x26409
movl 0x10(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl 0x2c(%rcx), %eax
je 0x26467
leaq 0x1050(%rsp), %rdi
callq 0x22940
movl %eax, 0xc(%rsp)
jmp 0x2642a
leaq 0x1050(%rsp), %rdi
callq 0x22950
movl %eax, 0x8(%rsp)
jmp 0x2643d
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %esi
movq 0x30(%rsp), %rax
movl 0x28(%rax), %ecx
movl 0x2c(%rax), %r8d
movq 0x38(%rax), %r9
leaq 0x140b0d(%rip), %rdi    # 0x166f69
xorl %eax, %eax
callq 0xdf990
jmp 0x26465
jmp 0x26467
jmp 0x26469
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movq 0xb8(%rax), %rax
leaq 0x1050(%rsp), %rsi
callq *%rax
movl %eax, 0x4(%rsp)
jmp 0x26488
movl 0x4(%rsp), %eax
movl %eax, 0x1074(%rsp)
movl $0x1, 0x38(%rsp)
leaq 0x1050(%rsp), %rdi
callq 0xd2160
movl 0x1074(%rsp), %eax
addq $0x1078, %rsp           # imm = 0x1078
retq
movq 0x40(%rsp), %rdi
callq 0x12c20
nopw %cs:(%rax,%rax)