private void CopyImageRect( WriteableBitmap dest, WriteableBitmap source, int xd, int yd, int xs, int ys, int dx, int dy ){
int dxd = dest.PixelWidth;
int dxs = source.PixelWidth;
int y,x;
for( y = 0; y < dy; y++){
for( x = 0; x < dx ; x++){
dest.Pixels[ (y+yd)*dxd + xd + x ] = source.Pixels[ (y+ys)*dxs + xs + x ];
}
}
}
BitmapImage source_wb = new BitmapImage( new Uri("/Assets/my_image.png", UriKind.Relative) );
bi.CreateOptions = BitmapCreateOptions.None;
WriteableBitmap dest_wb = new WriteableBitmap( 64, 64 );
CopyImageRect( dest_wb, source_wb, 64, 0, 0, 0, 64, 64);