[VB.NET]关于EXIF读取的详细问题,高手请进
来源:互联网 发布:java手动释放内存 编辑:程序博客网 时间:2024/05/01 02:51
<script type="text/javascript"><!--google_ad_client = "pub-8333940862668978";/* 728x90, 创建于 08-11-30 */google_ad_slot = "4485230109";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
关于EXIF读取的详细问题,高手请进
我要读取一个图片的EXIF信息, 信息中有汉字读不出来。
请大家给点源码吧~~THANK YOU
__________________________________________________________________________
我也想要。顶
__________________________________________________________________________
自己 up 下
__________________________________________________________________________
这里有段 c#的代码 那位高手帮我写成VB.NET
private void WriteNewDescriptionInImage(string Filename,string NewDescription)
{
Image Pic;
PropertyItem[] PropertyItems;
byte[] bDescription=new Byte[NewDescription.Length];
int i;
string FilenameTemp;
Encoder Enc=Encoder.Transformation;
EncoderParameters EncParms=new EncoderParameters(1);
EncoderParameter EncParm;
ImageCodecInfo CodecInfo=GetEncoderInfo( image/jpeg );
// copy description into byte array
for (i=0;i
// load the image to change
Pic=Image.FromFile(Filename);
// put the new description into the right property item
PropertyItems=Pic.PropertyItems;
PropertyItems[0].Id=0x010e; // 0x010e as specified in EXIF standard
PropertyItems[0].Type=2;
PropertyItems[0].Len=NewDescription.Length;
PropertyItems[0].Value=bDescription;
Pic.SetPropertyItem(PropertyItems[0]);
// we cannot store in the same image, so use a temporary image instead
FilenameTemp=Filename+ .temp ;
// for lossless rewriting must rotate the image by 90 degrees!
EncParm=new EncoderParameter(Enc,(long)EncoderValue.TransformRotate90);
EncParms.Param[0]=EncParm;
// now write the rotated image with new description
Pic.Save(FilenameTemp,CodecInfo,EncParms);
// for computers with low memory and large pictures: release memory now
Pic.Dispose();
Pic=null;
GC.Collect();
// delete the original file, will be replaced later
System.IO.File.Delete(Filename);
// now must rotate back the written picture
Pic=Image.FromFile(FilenameTemp);
EncParm=new EncoderParameter(Enc,(long)EncoderValue.TransformRotate270);
EncParms.Param[0]=EncParm;
Pic.Save(Filename,CodecInfo,EncParms);
// release memory now
Pic.Dispose();
Pic=null;
GC.Collect();
// delete the temporary picture
System.IO.File.Delete(FilenameTemp);
}
__________________________________________________________________________
上面的是写入EXIF信息
__________________________________________________________________________
Private Sub WriteNewDescriptionInImage(ByVal Filename As String, ByVal NewDescription As String)
Dim Pic As Image
Dim PropertyItems() As PropertyItem
Dim bDescription() As Byte = New Byte(NewDescription.Length) {}
Dim i As Integer
Dim FilenameTemp As String
Dim Enc As Encoder = Encoder.Transformation
Dim EncParms As EncoderParameters = New EncoderParameters(1)
Dim EncParm As EncoderParameter
Dim CodecInfo As ImageCodecInfo = GetEncoderInfo( image/jpeg )
copy description into byte array
For i = 0 To NewDescription.Length- 1 Step i + 1
load the image to changePic=Image.FromFile(Filename)
Next
put the new description into the right property item
PropertyItems=Pic.PropertyItems
PropertyItems(0).Id=0x010e 0x010e as specified in EXIF standard
PropertyItems(0).Type=2
PropertyItems(0).Len=NewDescription.Length
PropertyItems(0).Value=bDescription
Pic.SetPropertyItem(PropertyItems(0))
we cannot store in the same image, so use a temporary image instead
FilenameTemp=Filename+ .temp
for lossless rewriting must rotate the image by 90 degrees!
EncParm=New EncoderParameter(Enc,CType(EncoderValue.TransformRotate90, Long))
EncParms.Param(0)=EncParm
now write the rotated image with new description
Pic.Save(FilenameTemp,CodecInfo,EncParms)
for computers with low memory and large pictures: release memory now
Pic.Dispose()
Pic=Nothing
GC.Collect()
delete the original file, will be replaced later
System.IO.File.Delete(Filename)
now must rotate back the written picture
Pic=Image.FromFile(FilenameTemp)
EncParm=New EncoderParameter(Enc,CType(EncoderValue.TransformRotate270, Long))
EncParms.Param(0)=EncParm
Pic.Save(Filename,CodecInfo,EncParms)
release memory now
Pic.Dispose()
Pic=Nothing
GC.Collect()
delete the temporary picture
System.IO.File.Delete(FilenameTemp)
End Sub
__________________________________________________________________________
zzy1254(逍遥)
Dim CodecInfo As ImageCodecInfo = GetEncoderInfo( image/jpeg )
这个GetEncoderInfo有波澜线
上面的代码我已经改过
功能算是可以实现 英文字母可以写入 但要是写入的是汉字信息 就写不进去。
那位高人 给点相关资料
__________________________________________________________________________
for (i=0;i这句也有错
__________________________________________________________________________
zzy1254(逍遥) 写成。NET写错
正确写法应该是下面这个
For i = 0 To NewDescription.Length - 1
bDescription(i) = Asc(NewDescription(i))
Next i
__________________________________________________________________________
噢,这样啊,不好意思,转换完了也没有试就给你贴上来了
__________________________________________________________________________
这个我试拉 能够添加英文的信息 但汉字信息 添加不了
找高人呀
__________________________________________________________________________
关于EXIF读取的详细问题,高手请进
我要读取一个图片的EXIF信息, 信息中有汉字读不出来。
请大家给点源码吧~~THANK YOU
__________________________________________________________________________
我也想要。顶
__________________________________________________________________________
自己 up 下
__________________________________________________________________________
这里有段 c#的代码 那位高手帮我写成VB.NET
private void WriteNewDescriptionInImage(string Filename,string NewDescription)
{
Image Pic;
PropertyItem[] PropertyItems;
byte[] bDescription=new Byte[NewDescription.Length];
int i;
string FilenameTemp;
Encoder Enc=Encoder.Transformation;
EncoderParameters EncParms=new EncoderParameters(1);
EncoderParameter EncParm;
ImageCodecInfo CodecInfo=GetEncoderInfo( image/jpeg );
// copy description into byte array
for (i=0;i
// load the image to change
Pic=Image.FromFile(Filename);
// put the new description into the right property item
PropertyItems=Pic.PropertyItems;
PropertyItems[0].Id=0x010e; // 0x010e as specified in EXIF standard
PropertyItems[0].Type=2;
PropertyItems[0].Len=NewDescription.Length;
PropertyItems[0].Value=bDescription;
Pic.SetPropertyItem(PropertyItems[0]);
// we cannot store in the same image, so use a temporary image instead
FilenameTemp=Filename+ .temp ;
// for lossless rewriting must rotate the image by 90 degrees!
EncParm=new EncoderParameter(Enc,(long)EncoderValue.TransformRotate90);
EncParms.Param[0]=EncParm;
// now write the rotated image with new description
Pic.Save(FilenameTemp,CodecInfo,EncParms);
// for computers with low memory and large pictures: release memory now
Pic.Dispose();
Pic=null;
GC.Collect();
// delete the original file, will be replaced later
System.IO.File.Delete(Filename);
// now must rotate back the written picture
Pic=Image.FromFile(FilenameTemp);
EncParm=new EncoderParameter(Enc,(long)EncoderValue.TransformRotate270);
EncParms.Param[0]=EncParm;
Pic.Save(Filename,CodecInfo,EncParms);
// release memory now
Pic.Dispose();
Pic=null;
GC.Collect();
// delete the temporary picture
System.IO.File.Delete(FilenameTemp);
}
__________________________________________________________________________
上面的是写入EXIF信息
__________________________________________________________________________
Private Sub WriteNewDescriptionInImage(ByVal Filename As String, ByVal NewDescription As String)
Dim Pic As Image
Dim PropertyItems() As PropertyItem
Dim bDescription() As Byte = New Byte(NewDescription.Length) {}
Dim i As Integer
Dim FilenameTemp As String
Dim Enc As Encoder = Encoder.Transformation
Dim EncParms As EncoderParameters = New EncoderParameters(1)
Dim EncParm As EncoderParameter
Dim CodecInfo As ImageCodecInfo = GetEncoderInfo( image/jpeg )
copy description into byte array
For i = 0 To NewDescription.Length- 1 Step i + 1
load the image to changePic=Image.FromFile(Filename)
Next
put the new description into the right property item
PropertyItems=Pic.PropertyItems
PropertyItems(0).Id=0x010e 0x010e as specified in EXIF standard
PropertyItems(0).Type=2
PropertyItems(0).Len=NewDescription.Length
PropertyItems(0).Value=bDescription
Pic.SetPropertyItem(PropertyItems(0))
we cannot store in the same image, so use a temporary image instead
FilenameTemp=Filename+ .temp
for lossless rewriting must rotate the image by 90 degrees!
EncParm=New EncoderParameter(Enc,CType(EncoderValue.TransformRotate90, Long))
EncParms.Param(0)=EncParm
now write the rotated image with new description
Pic.Save(FilenameTemp,CodecInfo,EncParms)
for computers with low memory and large pictures: release memory now
Pic.Dispose()
Pic=Nothing
GC.Collect()
delete the original file, will be replaced later
System.IO.File.Delete(Filename)
now must rotate back the written picture
Pic=Image.FromFile(FilenameTemp)
EncParm=New EncoderParameter(Enc,CType(EncoderValue.TransformRotate270, Long))
EncParms.Param(0)=EncParm
Pic.Save(Filename,CodecInfo,EncParms)
release memory now
Pic.Dispose()
Pic=Nothing
GC.Collect()
delete the temporary picture
System.IO.File.Delete(FilenameTemp)
End Sub
__________________________________________________________________________
zzy1254(逍遥)
Dim CodecInfo As ImageCodecInfo = GetEncoderInfo( image/jpeg )
这个GetEncoderInfo有波澜线
上面的代码我已经改过
功能算是可以实现 英文字母可以写入 但要是写入的是汉字信息 就写不进去。
那位高人 给点相关资料
__________________________________________________________________________
for (i=0;i
__________________________________________________________________________
zzy1254(逍遥) 写成。NET写错
正确写法应该是下面这个
For i = 0 To NewDescription.Length - 1
bDescription(i) = Asc(NewDescription(i))
Next i
__________________________________________________________________________
噢,这样啊,不好意思,转换完了也没有试就给你贴上来了
__________________________________________________________________________
这个我试拉 能够添加英文的信息 但汉字信息 添加不了
找高人呀
__________________________________________________________________________
- [VB.NET]关于EXIF读取的详细问题,高手请进
- [VB.NET]关于程序性能问题,高手请进,谢谢
- vb.net高手请进
- 关于结束进程的问题,高手请进。
- [VB.NET]form初始化事件的解决方法,高手请进...
- [VB.NET]关于DataGridView的问题,会的请进来看看,帮忙解决!!
- [VB.NET]大容量文件编码转换问题,高手请进,在线等
- 截屏吃内存的问题 高手请进
- WCF的一个怪异问题,高手请进
- 高手请进,小妹请教一个ASP。NET安装问题
- [VB.NET]关于gridview的问题,急,高手们过来看看........
- 求助,查询问题,高手请进
- [VB.NET]跪求高手解决DataGrid的问题!
- [VB.NET]请教高手,还原数据库的问题?
- [VB.NET]关于VB.NET的打印功能 高手都跑那里去了?????
- 关于vb.net读取access数据库中的位图图片问题
- [VB.NET]vb.net+sql汇总表的问题!!!高手请指教!!!
- VB.net问题,高手支招!
- [VB.NET]急.....使用OWC11导出Excel,怎么生成多个工作薄..
- How to port native (C/C++) library into android.
- [VB.NET]treeView与数据库中的问题
- J2ME Polish 共有 36 个类似项目
- 给4个数从小到大的排序
- [VB.NET]关于EXIF读取的详细问题,高手请进
- [VB.NET]急求解答!怎样读取access中的图片
- [VB.NET]请问怎样修改自定义控件的缺省字体
- [VB.NET]vb.net的一个小问题
- [VB.NET].net下串口通讯问题--用mscomm控件无法使用大于16的串口port,急!
- [VB.NET]VB.NET怎样设计定时关机???
- js放礼花效果
- 【转】Java Util Logging技术介绍
- [VB.NET]怎样将字符串“AABBCCDDEE”变为“AA-BB-CC-DD-EE”,谢谢啦!