public void SetRemapTable(ColorMap[] map, ColorAdjustType type) { GdiColorMap gdiclr = new GdiColorMap(); IntPtr clrmap, lpPointer; int mapsize = Marshal.SizeOf(gdiclr); int size = mapsize * map.Length; clrmap = lpPointer = Marshal.AllocHGlobal(size); try { for (int i = 0; i < map.Length; i++) { gdiclr.from = map[i].OldColor.ToArgb(); gdiclr.to = map[i].NewColor.ToArgb(); Marshal.StructureToPtr(gdiclr, lpPointer, false); lpPointer = (IntPtr)(lpPointer.ToInt64() + mapsize); } Status status = GDIPlus.GdipSetImageAttributesRemapTable(nativeImageAttr, type, true, (uint)map.Length, clrmap); GDIPlus.CheckStatus(status); } finally { Marshal.FreeHGlobal(clrmap); } }
public void SetRemapTable (ColorMap[] map, ColorAdjustType type) { GdiColorMap gdiclr = new GdiColorMap (); IntPtr clrmap, lpPointer; int mapsize = Marshal.SizeOf (gdiclr); int size = mapsize * map.Length; clrmap = lpPointer = Marshal.AllocHGlobal (size); try { for (int i=0; i < map.Length; i++) { gdiclr.from = map[i].OldColor.ToArgb(); gdiclr.to = map[i].NewColor.ToArgb(); Marshal.StructureToPtr (gdiclr, lpPointer, false); lpPointer = (IntPtr) (lpPointer.ToInt64() + mapsize); } Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr, type, true, (uint) map.Length, clrmap); GDIPlus.CheckStatus (status); } finally { Marshal.FreeHGlobal (clrmap); } }