Convert byte() to image

NachitoMax 411 Reputation points
2021-01-13T01:05:56.6+00:00

Hi

Im having a little difficulty in converting a byte() to an image. The image is saved in SQL server and i think is was at some point, an Access Database (the previous programmer was mainly Access). In the SQL server field, it is set as an Image field.

I am collecting through a stored Procedure using a pair of BLL DAL classes. in the DAL class, i can only seem to successfully gat the data if i convert it to a Byte(). I have tried setting my reader.read and related properties to Bitmap & Byte(), Byte() doesnt give me an error.

Once i have the Byte() array, i need to convert it to an image for a picturebox. I have tried converting it to an image & also a bitmap but i get a error 'system.ArgumentException: 'Parameter is not valid' on the ConvertFrom line of example 1 & MemoryStream of example 2. My stack trace is at the bottom of the message.

an example of the image in the database is also at the bottom of this message

I have tried this

 Public Function byteArrayToImage(ByVal b As Byte()) As System.Drawing.Bitmap
            Dim bitmap As System.Drawing.Bitmap = Nothing

            Dim ic As System.Drawing.ImageConverter = New System.Drawing.ImageConverter()
            Dim img As System.Drawing.Image = CType(ic.ConvertFrom(b), System.Drawing.Image)
            bitmap = CType(img, System.Drawing.Bitmap)


            Return bitmap
        End Function

and this

Private Function ConvertyByteToImage(ByVal b As Byte) As Image
    Using mStream As New MemoryStream(b)
        Return Image.FromStream(mStream)
    End Using
End Function

So, looking at how the data is stored in the database below, how would i convert that back into an image?
Do i need to get the data as shown into my app and convert it there? if so, what method is best?
Do i need to change my DAL class to receive the image from the database as an image? if so, what is the best method?

This is the Helper method in my DAL Class that is used with the properties in the BLL Class. reader("part_image") is the image field in question

Protected Function ConvertFasteners(ByVal reader As SqlDataReader) As List(Of TRY.BLL.Fasteners_details)
            ConvertFasteners = New List(Of TRY.BLL.Fasteners_details)
            If reader.HasRows Then
                While reader.Read
                    ConvertFasteners.Add(New TRY.BLL.Fasteners_details(
                                         reader("id").ToString(),
                                         reader("desc").ToString(),
                                         reader("pn").ToString(),
                                         reader("KeySearch1").ToString(),
                                         reader("KeySearch2").ToString(),
                                         reader("Steel").ToString(),
                                         reader("Wood").ToString(),
                                         reader("Masonry").ToString(),
                                         reader("Aluminum").ToString(),
                                         reader("AlumCorner").ToString(),
                                         reader("obsolete").ToString(),
                                         reader("SetDefault").ToString(),
                                         reader("diameter").ToString(),
                                         reader("length").ToString(),
                                         reader("drill_hole").ToString(),
                                         reader("closest_drill").ToString(),
                                         reader("Category").ToString(),
                                         reader("family").ToString(),
                                         reader("LinkedFinish").ToString(),
                                         reader("Finish").ToString(),
                                         CBool(reader("ThermalBreak")),
                                         reader("part_image")))
                End While
            End If
        End Function

Any help greatly appreciated, ive scratching my head for a while now :)

Thanks

DATABASE IMAGE AS STORED

0x151C3700010000001000130014002400FFFFFFFF4175746F4341442044726177696E67004175746F4341442E44726177696E672E3230000105000002000000100000004163636573732E4F4C45324C696E6B00000000000000000000160000D0CF11E0A1B11AE1000000000000000000000000000000003E000300FEFF0900060000000000000000000000010000000100000000000000001000000200000001000000FEFFFFFF0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFEFFFFFFFEFFFFFF040000000500000006000000070000000800000009000000FEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF52006F006F007400200045006E00740072007900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000500FFFFFFFFFFFFFFFF02000000E0C6A9F7F2EF1A10818500DD01108C6B0000000000000000000000004095A805A4AFD60103000000000E00000000000001004F006C00650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A000200FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000000000000000000000000000000000005E0700000000000002004F006C0065005000720065007300300030003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180002010100000003000000FFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000001E000000080600000000000003004100630063006500730073004F0062006A00530069007400650044006100740061000000000000000000000000000000000000000000000000000000000026000200FFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000003700000038000000000000000100000002000000030000000400000005000000060000000700000008000000090000000A0000000B0000000C0000000D0000000E0000000F000000100000001100000012000000130000001400000015000000160000001700000018000000190000001A0000001B0000001C0000001D000000FEFFFFFF1F000000200000002100000022000000230000002400000025000000260000002700000028000000290000002A0000002B0000002C0000002D0000002E0000002F00000030000000310000003200000033000000340000003500000036000000FEFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF010000020000000001000000000000000000000000000000120700000303000000000000C00000000000004600003C0000005C5C6370692D7365727665722D66696C655C5453535F5368617265645C4D61737465725F506172745F496D616765735C575357313435382E647767001C00ADDE0000000000000000000000000000000002000000A00600007600000003005C005C006300700069002D007300650072007600650072002D00660069006C0065005C005400530053005F005300680061007200650064005C004D00610073007400650072005F0050006100720074005F0049006D0061006700650073005C0057005300570031003400350038002E006400770067001E06000005004C0000000114020000000000C0000000000000468202000020000000D0F9A07D40AED601D0F9A07D40AED601D0F9A07D40AED601018E010000000000010000000000000000000000000000006C0000001C0000000200000000000000000000001C0000004D00000031000000020000001400000000000000000002005C5C4350492D5345525645522D46494C455C5453535F534841524544004D61737465725F506172745F496D616765735C575357313435382E64776700EE0100000C0000A014001F580D1A2CF021BE504388B07367FC96EF3CBF000000B900BBAF933BAB000400000000002D000000315350537343E50ABE43AD4F85E469DC8633986E110000000B000000000B000000FFFF0000000000004D0000003153505330F125B7EF471A10A5F102608C9EEBAC310000000A000000001F000000100000006300700069002D007300650072007600650072002D00660069006C0065000000000000002D000000315350533AA4BDDEB337834391E74498DA2995AB1100000003000000001300000000000000000000000000000000003700C301C55C5C6370692D7365727665722D66696C655C5453535F536861726564004D6963726F736F6674204E6574776F726B0000020078003100000000005F518C8410004D61737465725F506172745F496D616765730000560009000400EFBE4E5133975F518C842E000000EFA308000000040000000000000000000000000000005EDD80004D00610073007400650072005F0050006100720074005F0049006D0061006700650073000000220062003200018E01005D5178B12000575357313435382E64776700480009000400EFBE5D5178B15D5178B12E000000DCB6080000000100000000000000000000000000000030B0050157005300570031003400350038002E0064007700670000001A00000014030000010000A05C5C6370692D7365727665722D66696C655C5453535F5368617265645C4D61737465725F506172745F496D616765735C575357313435382E6477670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005C005C006300700069002D007300650072007600650072002D00660069006C0065005C005400530053005F005300680061007200650064005C004D00610073007400650072005F0050006100720074005F0049006D0061006700650073005C0057005300570031003400350038002E0064007700670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000030000A058000000000000006370692D7365727665722D66696C650034771F340F80A040905D7947CDAA9804E97A137F5410EB11815700155D00190134771F340F80A040905D7947CDAA9804E97A137F5410EB11815700155D00190100000000FFFFFFFF48D79D1485EAA64593C5AC50D0260C9800000000FFFFFFFFB01C4305A4AFD601C0434305A4AFD601D0F9A07D40AED60100000000000000000000000000000000000000000000000000000000000000000000FFFFFFFF030000000400000001000000FFFFFFFF02000000000000004DC50000AE550000C6050000010009000003E302000002000502000000000400000003010800050000000B0200000000050000000C02D033507705020000F7000003000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000003402000003000000350004000000340200000300000035000500000004010D0000000500000002010100000008000000FA0200000100000000000000040000002D0101000800000025030200D90B511C516A511C0800000025030200153BE321DC0CE3210800000025030200DC0CE3212E01E3210800000025030200D90B511C2A00511C08000000250302002A00511C2A00F81508000000250302002E01511C2E01E32114000000250308003710FA11DA0D3312800B8B122C090013DE069213980442145C020F152A00F81514000000250308000076F815CF730F15927142144C6F9213FE6C0013AA6A8B1250683312F365FA110800000025030200516A511C0076511C0800000025030200516AF8150076F8150800000025030200FD74511CFD74E32108000000250302000076511C0076F81508000000250302004E69E321FD74E3210800000025030200153BE3214E69E3210800000025030200D90BF815516AF8150800000025030200D90BF8152A00F81508000000250302003710FA11F365FA110300000000000000000000000000000000000000000000004E414E490000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003800000000000000010000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000001050000050000000D0000004D45544146494C4550494354004DC5000052AAFFFFCE05000008004DC5AE550000010009000003E302000002000502000000000400000003010800050000000B0200000000050000000C02D033507705020000F7000003000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000003402000003000000350004000000340200000300000035000500000004010D0000000500000002010100000008000000FA0200000100000000000000040000002D0101000800000025030200D90B511C516A511C0800000025030200153BE321DC0CE3210800000025030200DC0CE3212E01E3210800000025030200D90B511C2A00511C08000000250302002A00511C2A00F81508000000250302002E01511C2E01E32114000000250308003710FA11DA0D3312800B8B122C090013DE069213980442145C020F152A00F81514000000250308000076F815CF730F15927142144C6F9213FE6C0013AA6A8B1250683312F365FA110800000025030200516A511C0076511C0800000025030200516AF8150076F8150800000025030200FD74511CFD74E32108000000250302000076511C0076F81508000000250302004E69E321FD74E3210800000025030200153BE3214E69E3210800000025030200D90BF815516AF8150800000025030200D90BF8152A00F81508000000250302003710FA11F365FA11030000000000DEAD05FE

STACK TRACE
System.ArgumentException
HResult=0x80070057
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.Image.FromStream(Stream stream)
at V2.PG_UQHW.ConvertToImage(Byte[] b) in C:\Users\me\source\repos\V2\V2\PAGES\Wizard\Pages\PRODUCTS\1. UNI\PG_UQHW.vb:line 204
at V2.PG_UQHW.PopulateProperties() in C:\Users\me\source\repos\V2\V2\PAGES\Wizard\Pages\PRODUCTS\1. UNI\PG_UQHWare.vb:line 157
at V2.PG_ProjectLoader.GoNext() in C:\Users\me\source\repos\V2\V2\PAGES\Wizard\Loaders\PG_ProjectLoader.vb:line 111
at V2.PG_WizardLoader.BtnNext_Click(Object sender, EventArgs e) in C:\Users\me\source\repos\V2\V2\PAGES\Wizard\Loaders\PG_WizardLoader.vb:line 61
at System.Windows.Forms.Control.OnClick(EventArgs e)
at DevExpress.XtraEditors.BaseButton.OnClick(EventArgs e)
at DevExpress.XtraEditors.BaseButton.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.Utils.Controls.ControlBase.BaseWndProc(Message& m)
at DevExpress.Utils.Controls.ControlBase.WndProc(Message& m)
at DevExpress.XtraEditors.BaseControl.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at DevExpress.XtraEditors.XtraForm.ShowDialog(IWin32Window owner)
at V2.Popups.ShowPupMsgWithUserControl(XtraUserControl usrControl, String MsgCaption, String MessageText, Boolean UseCancel) in C:\Users\me\source\repos\V2\V2\CLASSES\Popups.vb:line 70
at V2.FrmLoader.BarButtonItem6_ItemClick(Object sender, ItemClickEventArgs e) in C:\Users\me\source\repos\V2\V2\FrmLoader.vb:line 291
at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarButtonItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarItemLink.OnLinkClick()
at DevExpress.XtraBars.BarButtonItemLink.OnLinkClick()
at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPressItem(DXMouseEventArgs e, RibbonHitInfo hitInfo)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPress(DXMouseEventArgs e, RibbonHitInfo hitInfo)
at DevExpress.XtraBars.Ribbon.Handler.RibbonHandler.OnUnPress(DXMouseEventArgs e, RibbonHitInfo hitInfo)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnMouseUp(DXMouseEventArgs e)
at DevExpress.XtraBars.Ribbon.Handler.RibbonHandler.OnMouseUp(DXMouseEventArgs e)
at DevExpress.XtraBars.Ribbon.RibbonControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.Utils.Controls.ControlBase.BaseWndProc(Message& m)
at DevExpress.Utils.Controls.ControlBase.WndProc(Message& m)
at DevExpress.XtraBars.Ribbon.RibbonControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at DevExpress.Utils.Drawing.Helpers.NativeMethods.UnsafeNativeMethods.DefSubclassProc(IntPtr hWnd, IntPtr Msg, IntPtr wParam, IntPtr lParam)
at DevExpress.Utils.Drawing.Helpers.Win32SubclasserFactory.Win32Subclasser.SubClassProcInner(IntPtr hWnd, IntPtr Msg, IntPtr wParam, IntPtr lParam, IntPtr uIdSubclass, IntPtr dwRefData)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at V2.My.MyApplication.Main(String[] Args) in :line 81

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,370 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,706 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.1K Reputation points
    2021-01-13T09:28:32.153+00:00

    Change the type of b parameter: Private Function ConvertyByteToImage(ByVal b( ) As Byte) As Image….

    Make sure that the byte array, which is passed to ConvertyByteToImage, is valid. Use debugger to investigate the bytes got from database.

    Maybe these bytes are not an image? The first bytes — 15 1C 37… — does not seem to represent a signature of a usual image (https://en.wikipedia.org/wiki/List_of_file_signatures). Do you know how these bytes were obtained? Perhaps they represent a raw array of pixels that can be processed if you know the image size.

    Note that the bytes, converted to text, contains these substrings: “AutoCAD”, “.dwg”. Maybe these bytes represent a DWG file, not a picture?


2 additional answers

Sort by: Most helpful
  1. NachitoMax 411 Reputation points
    2021-01-14T05:49:55.197+00:00

    I reached out to the originator and its confirmed that they are Autocad DWG files. The frustrating part is they are stored in a database field named 'part_images'.. On top of that, they are actual OLE object links to files stored on the server..

    I have changed to my own images as they are easier to work with

    Thanks

    0 comments No comments

  2. Abdulhakim M. Elrhumi 351 Reputation points
    2021-01-14T20:45:26.723+00:00

    Hi

    private void gcEmployeeView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
    {

      label1.Text = gcEmployeeView.GetFocusedRowCellValue("Id").ToString();
           Byte[] image = (byte[])(gcEmployeeView.GetFocusedRowCellValue("Image_Employee"));
    
            MemoryStream ms = new MemoryStream(image);
            piBox.Image = Image.FromStream(ms);
    
    
    }
    

    private void picEmployee_Click(object sender, EventArgs e)
    {
    OpenFileDialog ofd = new OpenFileDialog();
    ofd.Filter = "Image File|.jpg;.png;.gif;.bmp";
    if (ofd.ShowDialog() == DialogResult.OK)
    {
    picEmployee.Image = Image.FromFile(ofd.FileName);

      }
    }
    

    Best Regards.
    Please remember to mark the replies as answers if they help.

    0 comments No comments