Windows Phone 8 blitting [英] Windows Phone 8 blitting

查看:85
本文介绍了Windows Phone 8 blitting的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows Phone 8(不是7.5)上是否可以进行blitting操作?我还没找到方法。我需要根据资产资源中的图像创建一个图像并对其进行blitting。那么。



  //  加载源图像 
BitmapImage bi = new BitmapImage( new Uri( / Assets / skin_01.png,UriKind.Relative));

// 创建新位图
WriteableBitmap wa_bmp = new WriteableBitmap( 64 64 );

// 如何从bi到wa_bmp进行blitting ???





谢谢。

解决方案

 < span class =code-keyword> 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 < span class =code-keyword>< 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。没有;

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


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.

//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.

解决方案

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);


这篇关于Windows Phone 8 blitting的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆