Delphi新版本虽然集成了PngImage但是分割复制什么的却非常难用.稍微封装了一下.可以把一张PNG
横向分割成N张.透明通道什么的都可以保持不变.typeTPngArray = array of TPngImage;procedure CopyPng(const Src: TPngImage; dest: TPngImage;const sOffset: Integer);vari, j, s: Integer;p1, p2: PByteArray;pa1, pa2: PByteArray;beginfor i := 0 to Src.Height - 1 dobeginp1 := Src.Scanline[i];p2 := dest.Scanline[i];pa1 := Src.AlphaScanline[i];pa2 := dest.AlphaScanline[i];for j := 0 to dest.Width - 1 dobegins := j + sOffset;p2[3 * j] := p1[3 * s];p2[3 * j + 1] := p1[3 * s + 1];p2[3 * j + 2] := p1[3 * s + 2];pa2[j] := pa1[s];end;end;end;function SplitePng(const Src: TPngImage; Count : Integer) : TPngArray;varI, lwidth,loffset : Integer;beginSetLength(Result, Count);lwidth := Src.Width div Count;loffset := 0;for i := 0 to Count -1 dobegin
Result[i] := TPngImage.CreateBlank(COLOR_RGBALPHA, 8, lwidth, Src.Height);CopyPng(Src, Result[i], lOffset);Inc(loffset, lwidth);end;end;