Pixel-Snapとか
SnapsToDevicePixelsプロパティをTrueにすることで、アンチエイリアスを無効化。
Keyboard.Focus(UIElement)
キーボードのフォーカスを取得させる。ImageとかでもOK。
画像リソース埋め込みメモ。
ビルドアクションは"Resource"、出力ディレクトリに「コピーしない」でOK。
<UserControl.Resources> <BitmapImage x:Key="Icon_Edit" UriSource="/Icon/pencil.png" /> <BitmapImage x:Key="Icon_ZoomIn" UriSource="/Icon/zoom_in.png" /> <BitmapImage x:Key="Icon_ZoomOut" UriSource="/Icon/zoom_out.png" /> <BitmapImage x:Key="Icon_ZoomReset" UriSource="/Icon/cabin.png" /> <BitmapImage x:Key="Icon_SaveAsPic" UriSource="/Icon/save_labled_edit.png" /> </UserControl.Resources>
http://code.msdn.microsoft.com/windowsdesktop/CVBXAML-WPF-Windows-WPF-0738a600
WPFでの画像出力処理。
//PNGでの出力サンプル。Encoderは他にもBMP、JPEG、GIFなどが存在。 bitmap = ... //対象の画像。writeableBitmapクラスとか。 PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap)); var dlg = new SaveFileDialog(); dlg.Filter = "PNG(*.png)|*.png"; if (dlg.ShowDialog() == true) { FileStream stream = new FileStream(dlg.FileName, FileMode.Create,FileAccess.Write); encoder.Save(stream); stream.Close(); }
writeableBitmapの場合、全体をちゃんと更新してから保存すること。
※エディタ等で見えている部分だけ描画する方式をとっている時、
見えてない部分が初期化状態のままで真っ黒という罠を回避するため。