Explorar o código

added clone()

ncannasse %!s(int64=11) %!d(string=hai) anos
pai
achega
6665ef7c4b
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      hxd/Pixels.hx

+ 12 - 0
hxd/Pixels.hx

@@ -151,6 +151,18 @@ class Pixels {
 		}
 	}
 
+	public function clone() {
+		var p = new Pixels(width, height, null, format);
+		p.flags = flags;
+		p.flags.unset(ReadOnly);
+		if( bytes != null ) {
+			var size = width * height * bytesPerPixel(format);
+			p.bytes = hxd.impl.Tmp.getBytes(size);
+			p.bytes.blit(0, bytes, offset, size);
+		}
+		return p;
+	}
+
 	public static function bytesPerPixel( format : PixelFormat ) {
 		return switch( format ) {
 		case ARGB, BGRA, RGBA: 4;