私はいくつかの画像処理が必要なWinRTアプリを開発しています。 私はWriteableBitmapex
を使用しています。画像の楕円上の特定のピクセルの色を変更しようとしています。 私の解決策は非常に遅いです。画像をタップして数分後。 なぜこのソリューションが遅いですか?何が別の方法ですか?WinRTアプリケーションで高速画像処理を行う方法は?
private void myimage_Tapped(object sender, TappedRoutedEventArgs e)
{
var xcor = e.GetPosition(sender as UIElement).X;
var ycor = e.GetPosition(sender as UIElement).Y;
Image ws = sender as Image;
int x = (int)(imag.PixelWidth * xcor/ws.ActualWidth);
int y = (int)(imag.PixelHeight * ycor/ws.ActualHeight);
var color = imag.GetPixel(x, y);
if (color.B != 0 && color.G != 0 && color.R != 0)
{
while (color.B != 0 && color.G != 0 && color.R != 0 && x < imag.PixelWidth)
{
x = x+1;
y = (int)(imag.PixelHeight * ycor/ws.ActualHeight);
while (color.B != 0 && color.G != 0 && color.R != 0 && y < imag.PixelHeight)
{
y = y + 1;
color = imag.GetPixel(x, y);
imag.SetPixel(x, y, Colors.Red);
}
}
}
}
あなたがXCOR、ycorに格納座標は何ですか? その楕円は何ですか? ピクセルが黒いときにwhilesを停止するのはなぜですか? – Piglet
@ピグレット楕円の色を変更するには、ストロークの色が黒で、xcorは楕円をクリックするようにしてください –