vb.net打開jpg vb打開程序

VB.net如何雙擊文件打開

我不知道我的理解是否正確,不過你先看看吧

創(chuàng)新互聯(lián)是一家業(yè)務(wù)范圍包括IDC托管業(yè)務(wù),網(wǎng)站空間、主機(jī)租用、主機(jī)托管,四川、重慶、廣東電信服務(wù)器租用,綿陽電信機(jī)房機(jī)柜租用,成都網(wǎng)通服務(wù)器托管,成都服務(wù)器租用,業(yè)務(wù)范圍遍及中國(guó)大陸、港澳臺(tái)以及歐美等多個(gè)國(guó)家及地區(qū)的互聯(lián)網(wǎng)數(shù)據(jù)服務(wù)公司。

以圖片為例,我的桌面有一個(gè) ?例圖.jpg ?的文件,我自己寫的程序 圖片瀏覽器.exe

將圖片的啟動(dòng)程序修改成 ?圖片瀏覽器.exe

圖片瀏覽器.exe 打開 ?例圖.jpg ?文件

解決方案如下,利用了?System.Environment.GetCommandLineArgs()函數(shù)

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

Dim?MyFile?As?String?=?""??'用以保存所打開的文件路徑?????????????????????

Dim?Parameters()?As?String??'用以保存數(shù)組參數(shù)??????????????????

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

原創(chuàng)程序哦

用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文件格式經(jīng)常在文件處理應(yīng)用程序中使用。您可以在基于.NET Framework的應(yīng)用程序中使用C#或VB.NET以編程方式將XPS或OXPS轉(zhuǎn)換為JPG或PNG圖像。

讓我們逐步介紹以下方案,以了解有關(guān)XPS轉(zhuǎn)換的更多信息:

使用C?;騐B.NET將XPS,OXPS轉(zhuǎn)換為JPG圖像

使用C?;騐B.NET將XPS,OXPS轉(zhuǎn)換為PNG圖像

目前,.NET版Aspose.page升級(jí)到v20.10版,感興趣的朋友可點(diǎn)擊下載

使用C#或VB.NET將XPS,OXPS轉(zhuǎn)換為JPG圖像

JPG文件之所以出名是因?yàn)樗鼈冊(cè)谒邢到y(tǒng)環(huán)境中均受支持。您可以使用C?;騐B.NET以編程方式將XPS或OXPS文件轉(zhuǎn)換為JPG圖像。對(duì)于XPS或OXPS到JPG圖像的轉(zhuǎn)換,應(yīng)遵循以下步驟:

加載輸入XPS或OXPS文件

初始化JpegSaveOptions對(duì)象

指定要渲染的SmoothingMode,Resolution和PageNumbers

保存輸出的JPG圖像

以下代碼顯示了如何使用C#語言將XPS或OXPS轉(zhuǎn)換為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?;騐B.NET將XPS,OXPS轉(zhuǎn)換為PNG圖像

可能需要使用C?;騐B.NET和Aspose.Page for .NET API將XPS或OXPS文件轉(zhuǎn)換為PNG。您需要按照以下步驟將XPS轉(zhuǎn)換為PNG:

加載輸入XPS或OXPS文件

初始化PngSaveOptions對(duì)象

設(shè)置圖像分辨率或頁面編號(hào)為渲染

保存輸出的PNG圖像

當(dāng)前標(biāo)題:vb.net打開jpg vb打開程序
URL鏈接:http://muchs.cn/article8/hgsdip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)外貿(mào)網(wǎng)站建設(shè)、云服務(wù)器自適應(yīng)網(wǎng)站、網(wǎng)站內(nèi)鏈域名注冊(cè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)