/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.36
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

namespace OSGeo.GDAL {

using System;
using System.Runtime.InteropServices;

public class ColorTable : MajorObject {
  private HandleRef swigCPtr;

  internal ColorTable(IntPtr cPtr, object cMemoryOwner) : base(GdalPINVOKE.ColorTableUpcast(cPtr), cMemoryOwner) {
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(ColorTable obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }
  internal static HandleRef getCPtrAndDisown(ColorTable obj, object cMemoryOwner) {
    obj.swigCMemOwner = cMemoryOwner;
    return getCPtr(obj);
  }

  ~ColorTable() {
    Dispose();
  }

  public override void Dispose() {
  lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwner == null) {
        swigCMemOwner = new object();
        GdalPINVOKE.delete_ColorTable(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
      base.Dispose();
    }
  }

  public ColorTable(PaletteInterp palette) : this(GdalPINVOKE.new_ColorTable((int)palette), null) {
    if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
  }

  public ColorTable Clone() {
    IntPtr cPtr = GdalPINVOKE.ColorTable_Clone(swigCPtr);
    ColorTable ret = (cPtr == IntPtr.Zero) ? null : new ColorTable(cPtr, ThisOwn_true());
    if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public PaletteInterp GetPaletteInterpretation() {
    PaletteInterp ret = (PaletteInterp)GdalPINVOKE.ColorTable_GetPaletteInterpretation(swigCPtr);
    if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetCount() {
    int ret = GdalPINVOKE.ColorTable_GetCount(swigCPtr);
    if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public ColorEntry GetColorEntry(int entry) {
    IntPtr cPtr = GdalPINVOKE.ColorTable_GetColorEntry(swigCPtr, entry);
    ColorEntry ret = (cPtr == IntPtr.Zero) ? null : new ColorEntry(cPtr, ThisOwn_false());
    if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetColorEntryAsRGB(int entry, ColorEntry centry) {
    int ret = GdalPINVOKE.ColorTable_GetColorEntryAsRGB(swigCPtr, entry, ColorEntry.getCPtr(centry));
    if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void SetColorEntry(int entry, ColorEntry centry) {
    GdalPINVOKE.ColorTable_SetColorEntry(swigCPtr, entry, ColorEntry.getCPtr(centry));
    if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
  }

  public void CreateColorRamp(int nStartIndex, ColorEntry startcolor, int nEndIndex, ColorEntry endcolor) {
    GdalPINVOKE.ColorTable_CreateColorRamp(swigCPtr, nStartIndex, ColorEntry.getCPtr(startcolor), nEndIndex, ColorEntry.getCPtr(endcolor));
    if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
  }

}

}
