在Windows手机中裁剪图像

时间:2014-06-08 10:51:18

标签: windows-phone-8 crop

Windows Phone 8使用visual studio 我试图通过移动摄像头捕获它后将图像裁剪为81个,但我发现了这个例外。任何帮助?

int halfWidth = (App.CroppedImage.PixelWidth / 9);
int halfHeight =(App.CroppedImage.PixelHeight / 9);
for (int row = 0; row < 9; row++)
    for (int col = 0; col < 9; col++)
    {
        WriteableBitmap wr = App.CroppedImage.Crop(col * halfHeight, row * halfWidth, halfWidth, halfHeight);
        MediaLibrary MLibrary = new MediaLibrary();
        IsolatedStorageFileStream IsoStoreFileStreams = myStore.CreateFile("test"+row+col+".jpg");
        Extensions.SaveJpeg(wr, IsoStoreFileStreams, 100, 100, 0, 85);
        IsoStoreFileStreams.Close();
        IsoStoreFileStreams = myStore.OpenFile("test"+ row + col +".jpg", FileMode.Open, FileAccess.Read);

        //Add the JPEG file to the photos library on the device.
        MediaLibrary libraryy = new MediaLibrary();
        Picture picc = library.SavePicture("Saved"+row+col+".jpg", IsoStoreFileStreams);
        IsoStoreFileStreams.Close();
    }

此函数中的异常 Extensions.SaveJpeg(wr, IsoStoreFileStreams, 100, 100, 0, 85); 消息是

  

Microsoft.Phone.ni.dll中出现“System.ArgumentException”类型的异常,但未在用户代码中处理

1 个答案:

答案 0 :(得分:0)

堆 对不起,我发现我的错误是`         WriteableBitmap wr = App.CroppedImage.Crop(col * halfWidth,row * halfHeight,halfWidth,halfHeight);

代替

WriteableBitmap wr = App.CroppedImage.Crop(col * halfHeight,row * halfWidth,halfWidth,halfHeight);

`