[英]Get image thumbnail from the path
inside my xamarin.mac application , I use SQLite to save database, profile picture is saved in database too, but I have problems with working big images (for ex. size 4 MB), I just need to save thumbnail of photo , while uploading : 在我的xamarin.mac应用程序中,我使用SQLite保存数据库,配置文件图片也保存在数据库中,但是我在处理大图像时遇到问题(例如大小为4 MB),我只需要保存照片的缩略图,同时上传:
imgProfilePicture.Image = new NSImage (path);
Byte [] bytes = System.IO.File.ReadAllBytes (path);
_profilePic = Convert.ToBase64String (bytes);
I save base64 string in db.. also , here is simple solution in c #: 我在db ..中保存了base64字符串, 这里是c#中的简单解决方案:
Image image = Image.FromFile(fileName);
Image thumb = image.GetThumbnailImage(120, 120, ()=>false, IntPtr.Zero);
thumb.Save(Path.ChangeExtension(fileName, "thumb"));
I need something like this, need to resize image without cropping it 我需要这样的东西,需要调整图像大小而不需要裁剪它
NSImage baseImage = new NSImage ("original.jpg", false);
NSImage tinyImage = new NSImage (new CoreGraphics.CGSize (32, 32));
tinyImage.LockFocus ();
baseImage.DrawInRect (new CoreGraphics.CGRect (0, 0, 32, 32), new CoreGraphics.CGRect (0, 0, baseImage.Size.Width, baseImage.Size.Height), NSCompositingOperation.Copy, 1.0f);
tinyImage.UnlockFocus ();
NSBitmapImageRep rep = new NSBitmapImageRep (tinyImage.AsTiff ());
NSData data = rep.RepresentationUsingTypeProperties (NSBitmapImageFileType.Jpeg);
data.Save ("tiny.jpg", true);
Which is https://stackoverflow.com/a/7576710/36782 converted to C# 哪个是https://stackoverflow.com/a/7576710/36782转换为C#
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.