vb.net打开jpg vb打开程序

VB.net如何双击文件打开

我不知道我的理解是否正确,不过你先看看吧

创新互联是一家业务范围包括IDC托管业务,网站空间、主机租用、主机托管,四川、重庆、广东电信服务器租用,绵阳电信机房机柜租用,成都网通服务器托管,成都服务器租用,业务范围遍及中国大陆、港澳台以及欧美等多个国家及地区的互联网数据服务公司。

以图片为例,我的桌面有一个  例图.jpg  的文件,我自己写的程序 图片浏览器.exe

将图片的启动程序修改成  图片浏览器.exe

图片浏览器.exe 打开  例图.jpg  文件

解决方案如下,利用了 System.Environment.GetCommandLineArgs()函数

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim MyFile As String = ""  '用以保存所打开的文件路径                     

Dim Parameters() As String  '用以保存数组参数                  

Dim i As Integer

Parameters= System.Environment.GetCommandLineArgs()

i = Parameters.GetUpperBound(0)                             

If i  0 Then                                 

MyFileName = Parameters(1)

PictureBox1.ImageLocation = MyFileName

End If

End Sub

参考文件:MSDN

原创程序哦

用VB.NET打开一张图片后,我怎样知道图片的格式?

Dim fmt As System.Drawing.Imaging.ImageFormat = PictureBox1.Image.RawFormat

If fmt.Equals(System.Drawing.Imaging.ImageFormat.Jpeg) Then

MsgBox("1")

ElseIf fmt.Equals(System.Drawing.Imaging.ImageFormat.Gif) Then

MsgBox("2")

End If

vbnet打开文件夹下打开jpg和png

XPS文件格式经常在文件处理应用程序中使用。您可以在基于.NET Framework的应用程序中使用C#或VB.NET以编程方式将XPS或OXPS转换为JPG或PNG图像。

让我们逐步介绍以下方案,以了解有关XPS转换的更多信息:

使用C#或VB.NET将XPS,OXPS转换为JPG图像

使用C#或VB.NET将XPS,OXPS转换为PNG图像

目前,.NET版Aspose.page升级到v20.10版,感兴趣的朋友可点击下载

使用C#或VB.NET将XPS,OXPS转换为JPG图像

JPG文件之所以出名是因为它们在所有系统环境中均受支持。您可以使用C#或VB.NET以编程方式将XPS或OXPS文件转换为JPG图像。对于XPS或OXPS到JPG图像的转换,应遵循以下步骤:

加载输入XPS或OXPS文件

初始化JpegSaveOptions对象

指定要渲染的SmoothingMode,Resolution和PageNumbers

保存输出的JPG图像

以下代码显示了如何使用C#语言将XPS或OXPS转换为JPG图像:

// Input file

string inputFileName = dataDir + "input.xps";

//Output file

string outputFileName = dataDir + "XPStoImage_out.jpeg";

// Initialize XPS input stream

using (Stream xpsStream = File.Open(inputFileName, FileMode.Open, FileAccess.Read))

{

// Load XPS document form the stream

XpsDocument document = new XpsDocument(xpsStream, new XpsLoadOptions());

// or load XPS document directly from file. No xpsStream is needed then.

// XpsDocument document = new XpsDocument(inputFileName, new XpsLoadOptions());

// Initialize options object with necessary parameters.

JpegSaveOptions options = new JpegSaveOptions()

{

SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality,

Resolution = 300

};

// Create rendering device for JPG format

ImageDevice device = new ImageDevice();

document.Save(device, options);

// Iterate through document partitions (fixed documents, in XPS terms)

for (int i = 0; i device.Result.Length; i++) // Iterate through partition pages for (int j = 0; j device.Result[i].Length; j++) { // Initialize image output stream using (Stream imageStream = System.IO.File.Open(Path.GetDirectoryName(outputFileName) + Path.GetFileNameWithoutExtension(outputFileName) + "_" + (i + 1) + "_" + (j + 1) + Path.GetExtension(outputFileName), System.IO.FileMode.Create, System.IO.FileAccess.Write)) // Write image imageStream.Write(device.Result[i][j], 0, device.Result[i][j].Length); } }

使用C#或VB.NET将XPS,OXPS转换为PNG图像

可能需要使用C#或VB.NET和Aspose.Page for .NET API将XPS或OXPS文件转换为PNG。您需要按照以下步骤将XPS转换为PNG:

加载输入XPS或OXPS文件

初始化PngSaveOptions对象

设置图像分辨率或页面编号为渲染

保存输出的PNG图像


网页名称:vb.net打开jpg vb打开程序
地址分享:http://myzitong.com/article/hgsdip.html