旋转位图图像

发布于 2024-12-03 04:10:26 字数 569 浏览 4 评论 0原文

我想旋转位图图像,我编写了一些代码并且它可以工作

TransformedBitmap TempImage = new TransformedBitmap();

TempImage.BeginInit();
TempImage.Source = MyImageSource; // MyImageSource of type BitmapImage

RotateTransform transform = new RotateTransform(90);
TempImage.Transform = transform;
TempImage.EndInit();

image1.Source = TempImage;

,但我希望 MyImageSource 得到此修改,因为像这样,如果我再次单击按钮,则不会发生任何事情,并且正常情况下它会得到我的图像的第一种形式,而且我希望它采用这种形式,因为我必须在修改后保存它。

为什么我必须这样做:

我有一些 tiff 图像要读取,其中一些可能不是正确的形式我想添加翻转 90° 用户单击它,直到图像返回到正确的形式,当他单击翻转时图像将以用户选择的实际形式保存(替换)在磁盘上

I want to rotate a bitmap image I wrote some code and it work

TransformedBitmap TempImage = new TransformedBitmap();

TempImage.BeginInit();
TempImage.Source = MyImageSource; // MyImageSource of type BitmapImage

RotateTransform transform = new RotateTransform(90);
TempImage.Transform = transform;
TempImage.EndInit();

image1.Source = TempImage;

but I want that MyImageSource get this modification, because like that if I click again in the button nothing happen and this normal it get the first form of my image, and also I want it to take this form because I have to save it after modification.

why I have to do this:

I have some tiff image to read some of them can be not in the right form I want to add flip 90° the user click on it until the image return to the right form and when he click on flip the image will be saved(replaced) on disk in the actual form chosen by user

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

逆流 2024-12-10 04:10:26

这个怎么样:

BitmapImage image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = new Uri(ImagePath);

// here
image.Rotation = Rotation.Rotate270; // or 90, 0, 180

image.EndInit();

How about this:

BitmapImage image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = new Uri(ImagePath);

// here
image.Rotation = Rotation.Rotate270; // or 90, 0, 180

image.EndInit();
昔日梦未散 2024-12-10 04:10:26

这个怎么样?

var transformBitmap = (TransformedBitmap)image1.Source;
RotateTransform rotateTransform = (RotateTransform)(transformBitmap.Transform);
rotateTransform.Angle += 90;
image1.Source = transformBitmap.Clone();

How about this?

var transformBitmap = (TransformedBitmap)image1.Source;
RotateTransform rotateTransform = (RotateTransform)(transformBitmap.Transform);
rotateTransform.Angle += 90;
image1.Source = transformBitmap.Clone();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文