Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is blitting operation available on Windows Phone 8 (not 7.5)? I have not found way. I need create an image and blitting to it from images in 'assets' resources. So.

C#
//load source image
BitmapImage bi = new BitmapImage( new Uri("/Assets/skin_01.png", UriKind.Relative) );

//create new bitmap
WriteableBitmap wa_bmp = new WriteableBitmap( 64, 64);

//how to blitting from bi to wa_bmp ???


Thank you.
Posted

1 solution

C#
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 ];
        }
    }
}
//EXAMPLE
//load image from assets
BitmapImage source_wb = new BitmapImage( new Uri("/Assets/my_image.png", UriKind.Relative) );
// WARNING this next line very important
bi.CreateOptions = BitmapCreateOptions.None;

WriteableBitmap dest_wb = new WriteableBitmap( 64, 64 );
//blitting
CopyImageRect( dest_wb, source_wb, 64, 0, 0, 0, 64, 64);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900