OOobbs2/75
質問
(書くページが無いのでとりあえずここに。) 変数に格納された画像データなどをダイアログコントロールなどに表示したいときに利用できます。 回答
com.sun.star.io.Pipe サービスを利用します。 手順は以下のとおり
Sub Main sURL = "file:///C:/usr/current_16.png" oSFA = CreateUnoService("com.sun.star.ucb.SimpleFileAccess") oInput = oSFA.openFileRead(sURL) Dim vData() oInput.readSomeBytes(vData,oInput.getLength()) oInput.closeInput() oPipe = CreateUnoService("com.sun.star.io.Pipe") oPipe.writeBytes(vData) oPipe.flush() oPipe.closeOutput() DialogLibraries.LoadLibrary("Standard") oDialog = CreateUnoDialog(DialogLibraries.Standard.Dialog1) oImgCtrl = oDialog.getControl("ImageControl1") oGP = CreateUnoService("com.sun.star.graphic.GraphicProvider") Dim oPRops(0) As New com.sun.star.beans.PropertyValue oProps(0).Name = "InputStream" oProps(0).Value = oPipe oGraphic = oGP.queryGraphic(oProps) oImgCtrl.setGraphics( oDialog.Peer.createGraphics() ) oImgCtrl.getModel().Graphic = oGraphic oDialog.execute() oPipe.closeInput() End Sub ダイアログがあるので ファイル:
sRight() = Split("89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 00 00 00 10 " &_ "00 00 00 10 08 03 00 00 00 28 2D 0F 53 00 00 00 06 50 4C 54 45 FF FF FF 00 " &_ "00 00 55 C2 D3 7E 00 00 00 01 74 52 4E 53 00 40 E6 D8 66 00 00 00 16 49 44 " &_ "41 54 78 9C 63 60 20 02 30 32 D2 57 08 4D 80 8A 5C 82 00 00 0D D0 00 19 E8 " &_ "1D 0F 7F 00 00 00 00 49 45 4E 44 AE 42 60 82"," ") sBytes = sRight Dim nBytes(UBound(sBytes())) As Integer For i = 0 To UBound(nBytes) nInt = Int(CDec("&H" & sBytes(i))) If nInt > 127 Then nInt = nInt - 256 nBytes(i) = nInt Next i oPipe = CreateUnoService("com.sun.star.io.Pipe") oPipe.writeBytes(nBytes) 続きは上記と同じ。スペースなどで区切らないデータの時には二文字ずつ変換が必要。
sTxt = "89504E470D0A1A0A0000000D4948445200000010000000100803000000282D0F5300000" &_ "006504C5445FFFFFF00000055C2D37E0000000174524E530040E6D8660000001649444154789" &_ "C636020093032D28A8B4580E6425800000DD00019C214388A0000000049454E44AE426082" Dim nBytes(Int((Len(sTxt)/2) -1)) As Integer For i = 0 To UBound(nBytes) nInt = Int(CDec("&H" & Mid(sTxt,i*2 +1,2))) If nInt > 127 Then nInt = nInt - 256 nBytes(i) = nInt Next i
感想,コメント,メモ
|