以上就是给各位分享c#–Bitmap.FromFile(路径)和新位图(路径)之间的差异,其中也会对c#图片路径进行解释,同时本文还将给你拓展.net–MailMessage,Sender和From属
以上就是给各位分享c# – Bitmap.FromFile(路径)和新位图(路径)之间的差异,其中也会对c#图片路径进行解释,同时本文还将给你拓展.net – MailMessage,Sender和From属性之间的差异、android – Google Map Distance和Directions API之间的差异、android – “Bitmap.createScaledBitmap”将32位图像转换为24位吗?、android – 使用Bitmap.Config.RGB_565将内存中的Bitmap转换为Bitmap等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- c# – Bitmap.FromFile(路径)和新位图(路径)之间的差异(c#图片路径)
- .net – MailMessage,Sender和From属性之间的差异
- android – Google Map Distance和Directions API之间的差异
- android – “Bitmap.createScaledBitmap”将32位图像转换为24位吗?
- android – 使用Bitmap.Config.RGB_565将内存中的Bitmap转换为Bitmap
c# – Bitmap.FromFile(路径)和新位图(路径)之间的差异(c#图片路径)
Bitmap bitmap1 = new Bitmap("C:\\test.bmp"); Bitmap bitmap2 = (Bitmap) Bitmap.FromFile("C:\\test.bmp");
一种选择比另一种更好吗? Bitmap.FromFile(path)是否会向位图图像填充任何其他数据,或者它只是新Bitmap(路径)的委托?
解决方法
在内部,他们几乎都这样做:
public static Image FromFile(String filename,bool useEmbeddedColorManagement) { if (!File.Exists(filename)) { IntSecurity.DemandReadFileIO(filename); throw new FileNotFoundException(filename); } filename = Path.GetFullPath(filename); IntPtr image = IntPtr.Zero; int status; if (useEmbeddedColorManagement) { status = SafeNativeMethods.Gdip.GdipLoadImageFromFileICM(filename,out image); } else { status = SafeNativeMethods.Gdip.GdipLoadImageFromFile(filename,out image); } if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); status = SafeNativeMethods.Gdip.GdipImageForceValidation(new HandleRef(null,image)); if (status != SafeNativeMethods.Gdip.Ok) { SafeNativeMethods.Gdip.GdipdisposeImage(new HandleRef(null,image)); throw SafeNativeMethods.Gdip.StatusException(status); } Image img = CreateImageObject(image); EnsureSave(img,filename,null); return img; }
和:
public Bitmap(String filename) { IntSecurity.DemandReadFileIO(filename); filename = Path.GetFullPath(filename); IntPtr bitmap = IntPtr.Zero; int status = SafeNativeMethods.Gdip.GdipCreateBitmapFromFile(filename,out bitmap); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); status = SafeNativeMethods.Gdip.GdipImageForceValidation(new HandleRef(null,bitmap)); if (status != SafeNativeMethods.Gdip.Ok) { SafeNativeMethods.Gdip.GdipdisposeImage(new HandleRef(null,bitmap)); throw SafeNativeMethods.Gdip.StatusException(status); } SetNativeImage(bitmap); EnsureSave(this,null); }
.net – MailMessage,Sender和From属性之间的差异
它们是否相同,如果没有,有没有理由使用发送方与From?
例如:
Using m As New System.Net.Mail.MailMessage() m.Sender = New System.Net.Mail.MailAddress("test@test.com","Name here") m.From = New System.Net.Mail.MailAddress("test@test.com","Name here") m.Subject = "Test" m.Body = "Test" Dim client As New System.Net.Mail.SmtpClient("mymailserver.com") client.Send(m) End Using
标题字段:
消息头应至少包括以下字段:
发件人:电子邮件地址,以及作者的姓名。在许多电子邮件客户端不可更改,除非通过更改帐户设置。
另请注意,“发件人:”字段不必是电子邮件的真实发件人。一个原因是,很容易伪造“From:”字段,并让一条消息似乎来自任何邮件地址。有可能对电子邮件进行数字签名,这是很难伪造的,但这种签名需要额外的编程,通常需要外部程序来验证。一些ISP不中继声称来自他们不托管的域的电子邮件,但很少(如果有的话)检查以确保该人或甚至在“From:”字段中命名的电子邮件地址是一个与连接相关联。一些ISP将电子邮件认证系统应用于通过其MTA发送的电子邮件,以允许其他MTA检测可能来自他们的伪造垃圾邮件。
发件人:代表作者在From:字段(秘书,列表管理器等)中列出的实际发件人的地址。
http://en.wikipedia.org/wiki/Email的详细信息
例如,gmail使用from / sender字段发送来自与您的gmail帐户(验证后)不同的电子邮件地址的电子邮件。
android – Google Map Distance和Directions API之间的差异
我试图搜索1和2之间的差异
My task is “When user moves from Source S to Destination D
using some path. We need to show the actual path user has traversed
on Google Map“
什么是实现它的最佳方法?
使用1.距离矩阵API或2.方向服务
解决方法
您可以使用路线服务通过各种交通方式获取从始发地到目的地的路线:步行,驾车,骑自行车,公共交通.获取从A点到B点的路线.
对于距离矩阵,它计算多个起点和目的地的行程距离和行程时间,可选择指定各种交通方式:步行,驾驶,骑自行车.
对于您的情况,我会建议路线服务,因为您不需要旅行时间.
android – “Bitmap.createScaledBitmap”将32位图像转换为24位吗?
Bitmap.Config mBitmapConfig; mBitmapConfig = Bitmap.Config.ARGB_8888; BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = mBitmapConfig; mBitmap = BitmapFactory.decodeFile(SourceFileName,options);
然后缩放:
mBitmap = Bitmap.createScaledBitmap(mBitmap,iW,iH,true);
如果我用于缩放原始位图的相同宽度和高度,则它是以兆字节为单位的1/2的大小(我正在观察堆大小).
将值“ARGB_8888”更改为“RGB_565”(24位)可在缩放后提供相同的大小(兆字节).
有人可以解释这个现象,可能会给我一个建议,如何在32位色彩空间中缩放位图?
谢谢!
解决方法
public static Bitmap createScaledBitmap(Bitmap src,int dstWidth,int dstHeight,boolean filter) { Matrix m; synchronized (Bitmap.class) { // small pool of just 1 matrix m = sScaleMatrix; sScaleMatrix = null; } if (m == null) { m = new Matrix(); } final int width = src.getWidth(); final int height = src.getHeight(); final float sx = dstWidth / (float)width; final float sy = dstHeight / (float)height; m.setScale(sx,sy); Bitmap b = Bitmap.createBitmap(src,width,height,m,filter); synchronized (Bitmap.class) { // do we need to check for null? why not just assign everytime? if (sScaleMatrix == null) { sScaleMatrix = m; } } return b; }
由于在方法体中进行了此检查,对createBitmap()的调用应该返回未更改的源位图:
if (!source.isMutable() && x == 0 && y == 0 && width == source.getWidth() && height == source.getHeight() && (m == null || m.isIdentity())) { return source; }
看一下这似乎是你的原始位图被返回,但是,如果你的位图恰好是可变的,你有效地跳过这个检查并最终在这里:
if (m == null || m.isIdentity()) { bitmap = createBitmap(neww,newh,source.hasAlpha() ? Config.ARGB_8888 : Config.RGB_565); paint = null; // not needed }
由于您没有执行任何缩放,您的矩阵将是单位矩阵,并且条件得到满足.如您所见,创建的位图依赖于源位图中的alpha.如果不存在alpha,则最终得到RGB_565格式的结果位图,而不是ARGB_8888.
因此,要缩放和保留32位格式,您的位图应该是不可变的或使用Alpha通道.
android – 使用Bitmap.Config.RGB_565将内存中的Bitmap转换为Bitmap
BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig=Bitmap.Config.RGB_565 bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.myphoto,options);
解决方法
private Bitmap convert(Bitmap bitmap,Bitmap.Config config) { Bitmap convertedBitmap = Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(),config); Canvas canvas = new Canvas(convertedBitmap); Paint paint = new Paint(); paint.setColor(Color.BLACK); canvas.drawBitmap(bitmap,paint); return convertedBitmap; }
调用这样的方法:
Bitmap convertedBitmap = convert(bitmap,Bitmap.Config.RGB_565);
如果您使用带有矩阵的drawBitmap,则可以进行各种其他转换,如旋转,拉伸等.
我们今天的关于c# – Bitmap.FromFile(路径)和新位图(路径)之间的差异和c#图片路径的分享已经告一段落,感谢您的关注,如果您想了解更多关于.net – MailMessage,Sender和From属性之间的差异、android – Google Map Distance和Directions API之间的差异、android – “Bitmap.createScaledBitmap”将32位图像转换为24位吗?、android – 使用Bitmap.Config.RGB_565将内存中的Bitmap转换为Bitmap的相关信息,请在本站查询。
本文标签: