Image display Problem

aavio
Member Posts: 143
Hello,
I had created a com dll that converts text to image (bmp) file,i hav a function 'DrawText' to convert it.In the C/AL Symbol Menu functions argument is shown as [VARIANT DrawText :=]DrawText(BSTR My Text)
when i tried to assign SourceExpr of picture box as the same function, it doesnt works...(not the problm with dll thats sure)
I also tried to assign Output of function to a variant type,But variant datatype cant hold a blob datatype naa...then
how can i assign variant datatype to a Picture Box?? plz help :?
I had created a com dll that converts text to image (bmp) file,i hav a function 'DrawText' to convert it.In the C/AL Symbol Menu functions argument is shown as [VARIANT DrawText :=]DrawText(BSTR My Text)
when i tried to assign SourceExpr of picture box as the same function, it doesnt works...(not the problm with dll thats sure)
I also tried to assign Output of function to a variant type,But variant datatype cant hold a blob datatype naa...then
how can i assign variant datatype to a Picture Box?? plz help :?
aav!o
0
Comments
-
Since you wrote a COM DLL just use a Stream and write to a temporary blob with it.
There is a nice example of Streaming on the downloads section, but if you can't manage to get it to work let me know and I'll post some code. (Although the example in the downloads section is written in C# if I remember correctly; my example would be in VB.NET :?)0 -
Thanks for ur reply,...
sorry i didnt find any example with streaming....can u plz provide exact path.. :?:
and also, iam calling this image convertion function from a report,... there i need to print it on...so in reports, blob global variables are not available. otherwise , i need to import these images to a table,but thr will be many images corresponding to a particular record, so if i could get a solution,that after converting to image and assigning it to a picture box that will be better.... do you hav a solution... [-o<aav!o0 -
For now here is a link to the Stream example found in the Downloads section.
"Access Navision Stream From DotNet" http://www.mibuso.com/dlinfo.asp?FileID=776
What language have you programmed the COM dll in?
I will have to test a little when I have some free time (lately which has been never); But I am sure you can pass a temporary table to a report. As far as sending a temp. table full of image BLOBs that will show up on the report, not sure. :?0 -
Anyways,
Here is my take on the COM <-> Navision stream handling (In VB.NET).
Based on Alexey Pavlov's code provided by the above link.Imports System.IO Imports System.Text Imports System.Runtime.InteropServices Imports System.Runtime.InteropServices.ComTypes Friend Class Stream Private utf8 As New UTF8Encoding Public Function WriteToStream(ByVal StreamData As String, _ <MarshalAs(UnmanagedType.AsAny)> ByVal ComObjOut As Object) As Integer Dim stream As IStream = TryCast(ComObjOut, IStream) Dim memStream As New MemoryStream Dim buffStreamData As Byte() = Nothing Dim buffStream As Byte() = New Byte(&HAFC8) {} Dim wBytes As IntPtr = IntPtr.Zero Dim _wBytes As Integer = 0 Dim twBytes As Integer = 0 If utf8.GetBytes(StreamData, 0, StreamData.Length, buffStreamData, 0) > 0 Then memStream.Write(buffStreamData, 0, buffStreamData.Length) wBytes = Marshal.AllocHGlobal(4) Do _wBytes = memStream.Read(buffStream, 0, buffStream.Length) Marshal.WriteInt32(wBytes, _wBytes) stream.Write(buffStream, _wBytes, wBytes) twBytes += _wBytes Loop While _wBytes > 0 Marshal.FreeHGlobal(wBytes) Return twBytes Else Return -1 End If End Function Public Function ReadFromStream(ByRef StreamData As String, _ <MarshalAs(UnmanagedType.AsAny)> ByVal ComObjIn As Object) As Integer Dim stream As IStream = TryCast(ComObjIn, IStream) Dim memStream As New MemoryStream Dim buffStream As Byte() = New Byte(&HAFC8) {} Dim rBytes As IntPtr = IntPtr.Zero Dim _rBytes As Integer = 0 Dim trBytes As Integer = 0 rBytes = Marshal.AllocHGlobal(4) Try Do stream.Read(buffStream, buffStream.Length, rBytes) _rBytes = Marshal.ReadInt32(rBytes) memStream.Write(buffStream, 0, _rBytes) trBytes += _rBytes Loop While _rBytes > 0 Finally Marshal.FreeHGlobal(rBytes) End Try If trBytes > 0 Then StreamData = utf8.GetString(memStream.ToArray) Return trBytes End Function End Class
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions