// create image source
Stream stream = file.OpenRead();
BitmapImage bmpImg = new BitmapImage();
bmpImg.SetSource(stream);
stream.Close();
// create temporary image from it
Image tmpImg = new Image();
tmpImg.Source = bmpImg;
// this is required by WriteableBitmap
tmpImg.Measure(new Size(100, 100));
tmpImg.Arrange(new Rect(0, 0, 100, 100));
// prepare scaling to 100×100
ScaleTransform scaleTrans = new ScaleTransform();
double scale = (double)100 / (double)Math.Max(bmpImg.PixelHeight, bmpImg.PixelWidth);
scaleTrans.CenterX = 0;
scaleTrans.CenterY = 0;
scaleTrans.ScaleX = scale;
scaleTrans.ScaleY = scale;
// render
WriteableBitmap writeableBitmap = new WriteableBitmap(100, 100);
writeableBitmap.Render(tmpImg, scaleTrans);
writeableBitmap.Invalidate();
// final image
Image img = new Image();
img.Source = writeableBitmap;
分享到:
相关推荐
This suite of Silverlight controls provides analytical processing features similar to those found in Microsoft Excel Pivot Tables and Pivot Charts. Drag-and-drop views give you real-time information,...
This suite of Silverlight controls provides analytical processing features similar to those found in Microsoft Excel Pivot Tables and Pivot Charts. Drag-and-drop views give you real-time information,...
This suite of Silverlight controls provides analytical processing features similar to those found in Microsoft Excel Pivot Tables and Pivot Charts. Drag-and-drop views give you real-time information,...
Radio Group Items - DevExpress Silverlight Menu controls allow you to join items into radio groups, thus allowing only one item in a group to be checked at a time. (Screenshot) Full Support for ...
- **Geometric Transformations**: Tools for resizing, rotating, and translating images. 3. **Artistic Effects** - **Stylization**: Creating artistic effects such as sketching, painting, and cartoon-...
VC代码 resizing_dlg_sample (实用代码源)VC代码 resizing_dlg_sample (实用代码源)VC代码 resizing_dlg_sample (实用代码源)VC代码 resizing_dlg_sample (实用代码源)VC代码 resizing_dlg_sample (实用代码源)VC...
2007年Shai Avidan 和Ariel Shamir论文《Seam Carving for Content-Aware Image Resizing》所提出方法的Matlab代码实现和作者的论文。 效果非常炫,而且代码不长
In the subsequent chapters, the author discusses core operations, such as image filtering, color enhancement, image resizing, and transcoding of images and videos, that are used in various image and ...
在标题"image resizing"和描述"image resizing program"中,我们聚焦的核心知识点是图像的大小调整。 图像缩放可以分为两种主要类型:放大和缩小。放大可能会导致像素的失真,因为图像被拉伸以填充更大的区域,而...
用progressive resizing提升CNN图像分类器性能,Boost your CNN image classifier performance with progressive resizing in Keras,by Aleksey Bilogur。
-Easy resizing by using windows explorer Send To menu -Automatic cropping option -Can read JPG, BMP, GIF, PNG, TIFF and HD Photo (.wdp, .hdp) files -Writes JPG, BMP or PNG files -Compatible with ...
Fixed : Issue with readonly cells when using columns in TTMSFMXGrid Fixed : Issue accessing correct cell colors in TTMSFMXGrid Fixed : Issue with displaying DetailView in TTMSFMXTableView v2.1.0.3...
"一个简单有效的实现图片Image Resizing and Cropping 缩放及裁剪控件代码"这一主题,主要涵盖了以下核心知识点: 1. 图片处理基础: - 图片格式:JPEG、PNG、BMP等常见图片格式的理解,包括它们的优缺点和适用...
"resizing_dlg_doc.zip"这个压缩包包含了一种解决方案,即一个专门用于处理窗口大小变化时控件自动调整的类——`cdxCSizingDialog`。这个类是由非中文开发者编写的,旨在帮助程序员更方便地处理窗口尺寸改变时的界面...
传统的等比例缩放技术,直接将图像整体缩放为目标尺寸,这样做通常会破坏图像内容的比例关系,因为会出现目标长宽比与源图像长宽比不一的情况,图像内容因此会受到损失,另一方面如果目标尺寸较小而源图像的重要信息...
Making GIF images with transparent backgrounds using GIMP 149 Diplomat walking at the palace 152 Spider in the forest 156 Moving band of images 160 Continuous band of images 162 Endless ...
:construction_worker: image-resizing 使用 Cloudflare 调整 Ghost 博客图像内容的图像大小 使用 Cloudflare 的自动压缩从上的content/images/路径提供的任何图像。 :information: 商业和企业可以调整图像大小 ...
Grid Resizing Error(解决方案).md