[Sloved] Convert image back from base64 encoding

Post

Posted
Rating:
#1 (In Topic #944)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
 Hi all,

Just wondered if this is possible I have some images that are stored in the database as a base64 encoding (so string) but this was encoded by a vb.net application

Do I have to convert the image back into a file before loading it to the picture box or can I load the image to the picture box direct from a memory of the image?
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
…try this command line:  :|

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   PictureBox1.Image.FromString(FromBase64("Base64_string"))
  4.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
 I tried

FrmPLUList.picturebox1.image.fromstring(frombase64(PLUDataResult!button_image))

Im getting a error message on the line saying Null object in PLUFunctions

I can list the base64 code if you want
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
Yes, attach the base64 string file or paste this string, for testing.

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

Code

0x2f396a2f34414151536b5a4a5267414241514541594142674141442f34514261525868705a674141545530414b6741414141674142514d4241415541414141424141414153674d44414145414141414241414141414645514141454141414142415141414146455241415141414141424141414f7731455341415141414141424141414f777741414141414141596167414143786a2f2f6241454d4143415947427759464341634842776b4a43416f4d4641304d4377734d47524954447851644768386548526f634843416b4c6963674969776a4842776f4e796b734d4445304e4451664a7a6b394f4449384c6a4d304d762f6241454d4243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f41414245494149494174414d4249674143455145444551482f7841416641414142425145424151454241514141414141414141414141514944424155474277674a4367762f784143314541414341514d444167514442515545424141414158304241674d4142424546456945785151595455574548496e45554d6f47526f51676a5172484246564c523843517a596e4b4343516f574678675a4769556d4a7967704b6a51314e6a63344f547044524556475230684a536c4e5556565a5857466c615932526c5a6d646f6157707a6448563264336835656f4f456859614869496d4b6b704f556c5a61586d4a6d616f714f6b7061616e714b6d7173724f3074626133754c6d367773504578636248794d6e4b3074505531646258324e6e6134654c6a354f586d352b6a7036764879382f5431397666342b66722f7841416641514144415145424151454241514542414141414141414141514944424155474277674a4367762f78414331455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f415066366a6e6d6a74344a4a70574352787158646a3041417954556c6331385162794f772b482b753345736f6955576272754f655377326763657563666a5142346a34672b4c2b74367a71326e57725444534e4a754a5638354956506d62436634354f76706e626a7233723254776c635232516254734246553551453838386a50313572354a764c673352696c597351724d636a6b484a48507365422b56652b65462f45393439707056336543314555696b41774d54776841364876307a6a6a6e4665526a716b71556f565630505370306c4b4d6f48744e464d696b5756466447444b7779434b6658724a707136504e436969696d415555555541464646464142525252514155555555414646464641425252525141555555554146464646414256612f73626255374365787659556d74726844484c47347947553952566d69674435672b4a6e675136566279584f6b784d626543515253774b4f774f4563666e672f676657707232647445304c77356137475736565a4157513442487935342b763841577656395a6b6a6e46773339386b2f72586c666a7262743075556638733166482f66517234326e6a58694b6b614574556e4c5879733748525754703032302b78376a34447558752f4374764c4a3934737749394b365775442b47562b73326a7a5775526c4745696a50596a6e2b512f4f75387236584c704b57476a62707039787a33767146464646646f42525252514155555555414646464641425252525141555555554146464646414252525251415555555541465a2b7133506b576a49702f65534461754f6f395456396a675a5046637a4e63473675476d503353634b505156354763343736745135592f464c5266717a6644302b655633736a6e722b776b4d4c41453549774b383138576162646e546f6d6b6a594c4649567a32773250384b3967756d42556973693673494e52735a3757635a53525370506365682f413138566871376f56566256486f314d50477247374f50384168316533466b306373545a6b682b526c50526c4e653232462f46667743534d34492b3870367161384c30645a6447314b53435869614a747234364e372f5131365070313459696c7a627477527950583272324b576154776549313170792f71364d70594731505463376d6971316e6552336351644f7663656c57612b7870314956594b6348644d38317078646d4646464657494b4b4b4b414369696967416f6f6f6f414b4b4b4b414369696d504971444c454165704e4a744a585944364b356678543438306a776a615158562f7743644a444a4f73544e436d3779776572483248586a6d7476533956736461734972375462754b36745a526c4a596d79442f39663271595649564665447568744e626c326969697245564e536b4d656e334444727349483438567a515079416567726f395655747074774232545035484e633070347858786e456a66316d43366376366e6f344e4c6b6671517a7456654673535939616e6e716c6e612b6653766d704e71647a31494b3862474a34777352473976716b53344b2f75707364782f4366356a385253364e714a6a2b556e4b4e2b6c6446645730642f597957386f7a484b75445842514c4c5958636c6e50784a453244376a7366787230644b744f3359316f326c486c5a36506158547775737354593966513130396c7145563075507576335531353170756f5941566a785733484e305a472b6842357254415a6e57774d72627836722f4934635468464937624e4c5850326d7353494173337a723639785776446651546a354847665138477673734a6d6d47784b3932566e326535354e53684f47364c4e4649445335723054454b4b4b54496f4157696b7a78554574354443506e635a394279616970556854584e4e3251306d39455435714b61346968584d6a41653363316d5847724f334549326a315057737835586b596c6d4a4a366b6d76447865653034653751584d2b2f542f676e56547773706179304e4f34316a71496c78376e725754635854795a65567a676570717450644a426e63636e307249757279533462424f46394b2b5778654f72346c32715376356444307147455331534b4869574b4858744c6e302b59455179447176554873523731652b444f68332f6833544e55734c71344d6c71626e666172324359475778324a505566374e56696d635972766644467435476e6559657368342b677230736872566c58564744393356762b76754978394b6d6f632f5859334b4b4b4b2b3250464754494a49586a50526c4b6e386134386778735662677163477579505375613171333869374d672b354c7a2f774c76587a58456d4763715561386673757a39482f414d48387a74775537536358314d7963353656526b47474e57327146317a5878557058647a324b656736316b2f684a72503852364b313943743761726d36684851645a463950714f3157564a527130726558654f5078726f6f565846324364345335346e6e396c6542674d4774367a7632546a5046503133777930386a58326d41435938797739412f7550662b64633962585a44474f5146585867715267673131564b5561697645366f546a566a64486351586b6376422b552b74584559675a7a78374775526875656d4457684465756e527a394b3550656959564d50663454703472796550685a572b6d61744c716b34484c412f55567a6b6570482b4a5161734c66786e717048307273705a68577071305a7466656363384a336962333972546569666c5457314f636a71423942574d4c324c2f616f4e394542774361336562563376555a6e39565838706f795855736f2b65526a375a714c3643714231456677702b6456354c3656786a64676567726b7159745364336473316868356472476c4a5048454d73777a364373793431426d4745776f397171504a366d7172535a4e6338716b702b534f756e68347831593533796554544d35714d76543478765941416b6b344141366d68524f6a52497536665a7665336b554b446c6a2b51376d765349596c6868534a426855474257526f476b47776738325a6358456735483977656e31396132362b3379544c336871547156463730767758592b647832495657646f37494b4b4b4b39773451717071466f4c79316150675031516e73617430566e5670527177644f61756d4f4d6e4633527755675a484b7343724b63454874544d69756831335469366d3769584c4b5033674863657463307877612f4d3877774e54423133546c74306664487634657171734c6f63795a7045646f6d79446a464b7241696c494272687530622b544c3845367944673839785658564e43733957587a485879726744695a4238333050714b72674d68794d6972734e3967425a422b4972736f34684c53526a4b456f766d67636464365071656c4d576b6a4d3041365378636a38523146527758366e6a4e6568787a4b7779707a5653363058544c386c7037564e352f6a5435472f4d5632326a555263635931704e484c5233536e76566c6268665772372b443763484d46334f6e7334446634553065464a67634c664b5237782f2f587247574662324e76725646395372396f4148576e6565505772716546332f41493777663842542f7743765671507739614a393935704437746766705566564a45764530656a755a486d6a31705644794843497a4832476136474c54725745355342426a31476635314f7a4a474f5371696e39557372746d5478612b796a6e50374d764a657365776637624155372b784a53506d6e52665861704e6173326f5738663865397651566d58476f797a634435563942575575574f6b6452786e576e354935356e6b2f34534f50526b6a4c3345702f6476754156683148552f68786d76523944384e7861616f6d6e4b7a58583937487970395038613468394c68314b654e3233783345545a686e6a78766a623147515258714e7572706278724b356b6b565147636a473434354e6655354654773165382b58333432395056486e343670566a376a656a4a5252525258314a35595555555541464646464143455a466372726d6b47335a727133544d4a3564522f42372f542b566458534e6a427a58466a38425378744c6b6e76306659326f5670555a6330547a674848537056664e6257722b48324261347346794f7251662f452f34567a666d594f4f684855456369767a3347356657776b2b536f76523947652f53717772787645746b67303072554379314b73675065754678614e4c4e44777a716371784830717a4866544c7751472b7456647770636a7656526e4b4877736955564c6447694e525544356f7a2b427077314f502b34395a755236305a48725736786c56497a644342706e556b374931527471546337554834315133436d7339533856576c314255496469784a66544d5076342b6c55336b5a7a387a452f553031337146704b6a33706174334e6f775332484d525554483573564738774865744c51744b6b315735387877567455507a50362b777270772b4771567071464e5862484f63595263355051325044576c6d5268647972694e543867503841456638414156317452524b6b55617878714652526741646855674f612f517376774d4d4852564f4f2f563932664f56367a7254356d4c525252586359685252525141555555554146526e3171516a4e4d495070514245373446596572616661337838787759352f2b65716466784865747152474934552f6c5766635773726445632f6761797130616461484a5556305643636f506d69374d347535746269305968384f765a3036666a36564373766f6133723353373251485a424c30374961356937304c5834324c5731724f6659776b69766d385877326e3732486c386e2f6d6572537a507056587a5264576248656e6961735551654a6f2b4a6442753339346f322f6b522f576e71327235772b683671763841323579482b514e654a567962463039345035612f6b64304d54516e744a666b62486e65394c357739617a30683152782f794374514831744a422f4e616b4e7271662f514c762f38417747662f4141726c6542724c37442b343135716638792b38746d636574525063416436707951366b6f79644b31492f537a6c50386c716e4964587a694c772f72442b2f324e31483667567254797a4554656b4839784c725559377958336d67317a373158653578337167624c78544f635236446452413935596d503641442b64587248773772336d4235375734422f36354566307231734e7739586d37314c5258337334363259306f3651314e4454644d61376c5753374a6a6836374239357638425863326b6b6355537851717152714d4b716a67567a396a704e39474276676d48315131755731704d6f47593348315531395067384252776b6255317233366e6b3138524f733779324e4f4e39777159476f496f334856542b565467483072734d52344f525330555541464646464142525252514155555555414646464641425252525141555555554146464646414252525251415555555541464646464142525252514155555555414646464641482f2f5a

That is the base64 code

AS the images are loading on the VB.net version This is the code I am using

Code (gambas)

  1.     Public Sub StringDataToImage(ByVal StrData As String, ByVal ImageFile As PictureBox)
  2.         Dim bytes() As Byte = Convert.FromBase64String(StrData)
  3.         Dim MS As New System.IO.MemoryStream(bytes)
  4.         Dim bmp As Image = Image.FromStream(MS)
  5.         ImageFile.Image = bmp
  6.     End Sub
  7.  
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
vuott is in the usergroup ‘Regular’
Well, we have 2 problems.

1) About the "Null object" error it is caused by the command line, which :? I suggested you.
It should be changed as follows:

Code (gambas)

  1. PictureBox1.Image = Image.FromString(FromBase64("Base64_string"))
2) The string of values, you pasted here, is represented by single ASCII numeric characters. Each pair of these individual numeric characters "graphically " represents a numeric value in hexadecimal format.
We must, therefore, convert any pair of ASCII numeric characters into its corresponding actual numeric value and then into the corresponding string value.

Well, here a basic example using your provided data:

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3. ' Your attached data:
  4.   Dim s As String = "0x2f396a2f34414151536b5a4a5267414241514541594142674141442f34514261525868705a674141545530414b6741414141674142514d4241415541414141424141414153674d44414145414141414241414141414645514141454141414142415141414146455241415141414141424141414f7731455341415141414141424141414f777741414141414141596167414143786a2f2f6241454d4143415947427759464341634842776b4a43416f4d4641304d4377734d47524954447851644768386548526f634843416b4c6963674969776a4842776f4e796b734d4445304e4451664a7a6b394f4449384c6a4d304d762f6241454d4243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f41414245494149494174414d4249674143455145444551482f7841416641414142425145424151454241514141414141414141414141514944424155474277674a4367762f784143314541414341514d444167514442515545424141414158304241674d4142424546456945785151595455574548496e45554d6f47526f51676a5172484246564c523843517a596e4b4343516f574678675a4769556d4a7967704b6a51314e6a63344f547044524556475230684a536c4e5556565a5857466c615932526c5a6d646f6157707a6448563264336835656f4f456859614869496d4b6b704f556c5a61586d4a6d616f714f6b7061616e714b6d7173724f3074626133754c6d367773504578636248794d6e4b3074505531646258324e6e6134654c6a354f586d352b6a7036764879382f5431397666342b66722f7841416641514144415145424151454241514542414141414141414141514944424155474277674a4367762f78414331455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f415066366a6e6d6a74344a4a70574352787158646a3041417954556c6331385162794f772b482b753345736f6955576272754f655377326763657563666a5142346a34672b4c2b74367a71326e57725444534e4a754a5638354956506d62436634354f76706e626a7233723254776c635232516254734246553551453838386a50313572354a764c673352696c597351724d636a6b484a48507365422b56652b65462f45393439707056336543314555696b41774d54776841364876307a6a6a6e4665526a716b71556f565630505370306c4b4d6f48744e464d696b5756466447444b7779434b6658724a707136504e436969696d415555555541464646464142525252514155555555414646464641425252525141555555554146464646414256612f73626255374365787659556d74726844484c47347947553952566d69674435672b4a6e675136566279584f6b784d626543515253774b4f774f4563666e672f676657707232647445304c77356137475736565a4157513442487935342b763841577656395a6b6a6e46773339386b2f72586c666a7262743075556638733166482f66517234326e6a58694b6b614574556e4c5879733748525754703032302b78376a34447558752f4374764c4a3934737749394b365775442b47562b73326a7a5775526c4745696a50596a6e2b512f4f75387236584c704b57476a62707039787a33767146464646646f42525252514155555555414646464641425252525141555555554146464646414252525251415555555541465a2b7133506b576a49702f65534461754f6f395456396a675a5046637a4e63473675476d503353634b505156354763343736745135592f464c5266717a6644302b655633736a6e722b776b4d4c41453549774b383138576162646e546f6d6b6a594c4649567a32773250384b3967756d42556973693673494e52735a3757635a53525370506365682f413138566871376f56566256486f314d50477247374f50384168316533466b306373545a6b682b526c50526c4e653232462f46667743534d34492b3870367161384c30645a6447314b53435869614a747234364e372f5131365070313459696c7a627477527950583272324b576154776549313170792f71364d70594731505463376d6971316e6552336351644f7663656c57612b7870314956594b6348644d38317078646d4646464657494b4b4b4b414369696967416f6f6f6f414b4b4b4b414369696d504971444c454165704e4a744a585944364b356678543438306a776a615158562f7743644a444a4f73544e436d3779776572483248586a6d7476533956736461734972375462754b36745a526c4a596d79442f39663271595649564665447568744e626c326969697245564e536b4d656e334444727349483438567a515079416567726f395655747074774232545035484e633070347858786e456a66316d43366376366e6f344e4c6b6671517a7456654673535939616e6e716c6e612b6653766d704e71647a31494b3862474a34777352473976716b53344b2f75707364782f4366356a385253364e714a6a2b556e4b4e2b6c6446645730642f597957386f7a484b75445842514c4c5958636c6e50784a453244376a7366787230644b744f3359316f326c486c5a36506158547775737354593966513130396c7145563075507576335531353170756f5941566a785733484e305a472b6842357254415a6e57774d72627836722f4934635468464937624e4c5850326d7353494173337a723639785776446651546a354847665138477673734a6d6d47784b3932566e326535354e53684f47364c4e4649445335723054454b4b4b54496f4157696b7a78554574354443506e635a394279616970556854584e4e3251306d39455435714b61346968584d6a41653363316d5847724f334549326a315057737835586b596c6d4a4a366b6d76447865653034653751584d2b2f542f676e56547773706179304e4f34316a71496c78376e725754635854795a65567a676570717450644a426e63636e307249757279533462424f46394b2b5778654f72346c32715376356444307147455331534b4869574b4858744c6e302b59455179447176554873523731652b444f68332f6833544e55734c71344d6c71626e666172324359475778324a505566374e56696d635972766644467435476e6559657368342b677230736872566c58564744393356762b76754978394b6d6f632f5859334b4b4b4b2b3250464754494a49586a50526c4b6e386134386778735662677163477579505375613171333869374d672b354c7a2f774c76587a58456d4763715561386673757a39482f414d48387a74775537536358314d7963353656526b47474e57327146317a5878557058647a324b656736316b2f684a72503852364b313943743761726d36684851645a463950714f3157564a527130726558654f5078726f6f565846324364345335346e6e396c6542674d4774367a7632546a5046503133777930386a58326d41435938797739412f7550662b64633962585a44474f5146585867715267673131564b5561697645366f546a566a64486351586b6376422b552b74584559675a7a78374775526875656d4457684465756e527a394b3550656959564d50663454703472796550685a572b6d61744c716b34484c412f55567a6b6570482b4a5161734c66786e717048307273705a68577071305a7466656363384a336962333972546569666c5457314f636a71423942574d4c324c2f616f4e394542774361336562563376555a6e39565838706f795855736f2b65526a375a714c3643714231456677702b6456354c3656786a64676567726b7159745364336473316868356472476c4a5048454d73777a364373793431426d4745776f397171504a366d7172535a4e6338716b702b534f756e68347831593533796554544d35714d76543478765941416b6b344141366d68524f6a52497536665a7665336b554b446c6a2b51376d765349596c6868534a426855474257526f476b47776738325a6358456735483977656e31396132362b3379544c336871547156463730767758592b647832495657646f37494b4b4b4b39773451717071466f4c79316150675031516e73617430566e5670527177644f61756d4f4d6e4633527755675a484b7343724b63454874544d69756831335469366d3769584c4b5033674863657463307877612f4d3877774e54423133546c74306664487634657171734c6f63795a7045646f6d79446a464b7241696c494272687530622b544c3845367944673839785658564e43733957587a485879726744695a4238333050714b72674d68794d6972734e3967425a422b4972736f34684c53526a4b456f766d67636464365071656c4d576b6a4d3041365378636a38523146527758366e6a4e6568787a4b7779707a5653363058544c386c7037564e352f6a5435472f4d5632326a555263635931704e484c5233536e76566c6268665772372b443763484d46334f6e7334446634553065464a67634c664b5237782f2f587247574662324e76725646395372396f4148576e6565505772716546332f41493777663842542f7743765671507739614a393935704437746766705566564a45764530656a755a486d6a31705644794843497a4832476136474c54725745355342426a31476635314f7a4a474f5371696e39557372746d5478612b796a6e50374d764a657365776637624155372b784a53506d6e52665861704e6173326f5738663865397651566d58476f797a634435563942575575574f6b6452786e576e354935356e6b2f34534f50526b6a4c3345702f6476754156683148552f68786d76523944384e7861616f6d6e4b7a58583937487970395038613468394c68314b654e3233783345545a686e6a78766a623147515258714e7572706278724b356b6b565147636a473434354e6655354654773165382b58333432395056486e343670566a376a656a4a5252525258314a35595555555541464646464143455a466372726d6b47335a727133544d4a3564522f42372f542b566458534e6a427a58466a38425378744c6b6e76306659326f5670555a6330547a674848537056664e6257722b48324261347346794f7251662f452f34567a666d594f4f684855456369767a3347356657776b2b536f76523947652f53717772787645746b67303072554379314b73675065754678614e4c4e44777a716371784830717a4866544c7751472b7456647770636a7656526e4b4877736955564c6447694e525544356f7a2b427077314f502b34395a755236305a48725736786c56497a644342706e556b374931527471546337554834315133436d7339533856576c314255496469784a66544d5076342b6c55336b5a7a387a452f553031337146704b6a33706174334e6f775332484d525554483573564738774865744c51744b6b315735387877567455507a50362b777270772b4771567071464e5862484f63595263355051325044576c6d5268647972694e543867503841456638414156317452524b6b55617878714652526741646855674f612f517376774d4d4852564f4f2f563932664f56367a7254356d4c525252586359685252525141555555554146526e3171516a4e4d495070514245373446596572616661337838787759352f2b65716466784865747152474934552f6c5766635773726445632f6761797130616461484a5556305643636f506d69374d347535746269305968384f765a3036666a36564373766f6133723353373251485a424c30374961356937304c5834324c5731724f6659776b69766d385877326e3732486c386e2f6d6572537a507056587a5264576248656e6961735551654a6f2b4a6442753339346f322f6b522f576e71327235772b683671763841323579482b514e654a567962463039345035612f6b64304d54516e744a666b62486e65394c357739617a30683152782f794374514831744a422f4e616b4e7271662f514c762f38417747662f4141726c6542724c37442b343135716638792b38746d636574525063416436707951366b6f79644b31492f537a6c50386c716e4964587a694c772f72442b2f324e31483667567254797a4554656b4839784c725559377958336d67317a373158653578337167624c78544f635236446452413935596d503641442b64587248773772336d4235375734422f36354566307231734e7739586d37314c5258337334363259306f3651314e4454644d61376c5753374a6a6836374239357638425863326b6b6355537851717152714d4b716a67567a396a704e39474276676d48315131755731704d6f47593348315531395067384252776b6255317233366e6b3138524f733779324e4f4e39777159476f496f334856542b565467483072734d52344f525330555541464646464142525252514155555555414646464641425252525141555555554146464646414252525251415555555541464646464142525252514155555555414646464641482f2f5a"
  5.  
  6.  
  7. ' It starts from the 3rd numeric character, skipping the first two characters that are there to indicate that they are hexadecimal numbers (each pair of numeric characters represents an actual numeric value in hexadecimal format).
  8. ' It reads 2 numeric characters at a time, and therefore jumps by two numeric characters each time, to avoid reading a character at each cycle.
  9.   For c As Short = 2 To (s.Len - 1) Step 2
  10. ' Converts the two numeric characters to the corresponding actual numeric value and then converts it to the corresponding ASCII string value. It assigns this string value to a string type variable, adding it to the other values already assigned:
  11.     t &= Chr(Val("&" & s[c, 2]))
  12.   Next
  13.  
  14. ' It converts from the base64 string type and generates an Image type which is assigned to the "PictureBox":
  15.   PictureBox1.Image = Image.FromString(FromBase64(t))
  16.  
Well, with this my code I can see in "PictureBox" a little image with two bananas.   :)

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#7
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
I think I have a issue with the recall of the String fromt he database


When I recall the string I get

Code

"/9j/4AAQSkZJRgABAQEAYABgAAD/4QBaRXhpZgAATU0AKgAAAAgABQMBAAUAAAABAAAASgMDAAEAAAABAAAAAFEQAAEAAAABAQAAAFERAAQAAAABAAAOw1ESAAQAAAABAAAOwwAAAAAAAYagAACxj//bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicgIiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAIIAtAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQ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same as what I have in the database

Code

0x2f396a2f34414151536b5a4a5267414241514541594142674141442f34514261525868705a674141545530414b6741414141674142514d4241415541414141424141414153674d44414145414141414241414141414645514141454141414142415141414146455241415141414141424141414f7731455341415141414141424141414f777741414141414141596167414143786a2f2f6241454d4143415947427759464341634842776b4a43416f4d4641304d4377734d47524954447851644768386548526f634843416b4c6963674969776a4842776f4e796b734d4445304e4451664a7a6b394f4449384c6a4d304d762f6241454d4243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f41414245494149494174414d4249674143455145444551482f7841416641414142425145424151454241514141414141414141414141514944424155474277674a4367762f784143314541414341514d444167514442515545424141414158304241674d4142424546456945785151595455574548496e45554d6f47526f51676a5172484246564c523843517a596e4b4343516f574678675a4769556d4a7967704b6a51314e6a63344f547044524556475230684a536c4e5556565a5857466c615932526c5a6d646f6157707a6448563264336835656f4f456859614869496d4b6b704f556c5a61586d4a6d616f714f6b7061616e714b6d7173724f3074626133754c6d367773504578636248794d6e4b3074505531646258324e6e6134654c6a354f586d352b6a7036764879382f5431397666342b66722f7841416641514144415145424151454241514542414141414141414141514944424155474277674a4367762f78414331455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f415066366a6e6d6a74344a4a70574352787158646a3041417954556c6331385162794f772b482b753345736f6955576272754f655377326763657563666a5142346a34672b4c2b74367a71326e57725444534e4a754a5638354956506d62436634354f76706e626a7233723254776c635232516254734246553551453838386a50313572354a764c673352696c597351724d636a6b484a48507365422b56652b65462f45393439707056336543314555696b41774d54776841364876307a6a6a6e4665526a716b71556f565630505370306c4b4d6f48744e464d696b5756466447444b7779434b6658724a707136504e436969696d415555555541464646464142525252514155555555414646464641425252525141555555554146464646414256612f73626255374365787659556d74726844484c47347947553952566d69674435672b4a6e675136566279584f6b784d626543515253774b4f774f4563666e672f676657707232647445304c77356137475736565a4157513442487935342b763841577656395a6b6a6e46773339386b2f72586c666a7262743075556638733166482f66517234326e6a58694b6b614574556e4c5879733748525754703032302b78376a34447558752f4374764c4a3934737749394b365775442b47562b73326a7a5775526c4745696a50596a6e2b512f4f75387236584c704b57476a62707039787a33767146464646646f42525252514155555555414646464641425252525141555555554146464646414252525251415555555541465a2b7133506b576a49702f65534461754f6f395456396a675a5046637a4e63473675476d503353634b505156354763343736745135592f464c5266717a6644302b655633736a6e722b776b4d4c41453549774b383138576162646e546f6d6b6a594c4649567a32773250384b3967756d42556973693673494e52735a3757635a53525370506365682f413138566871376f56566256486f314d50477247374f50384168316533466b306373545a6b682b526c50526c4e653232462f46667743534d34492b3870367161384c30645a6447314b53435869614a747234364e372f5131365070313459696c7a627477527950583272324b576154776549313170792f71364d70594731505463376d6971316e6552336351644f7663656c57612b7870314956594b6348644d38317078646d4646464657494b4b4b4b414369696967416f6f6f6f414b4b4b4b414369696d504971444c454165704e4a744a585944364b356678543438306a776a615158562f7743644a444a4f73544e436d3779776572483248586a6d7476533956736461734972375462754b36745a526c4a596d79442f39663271595649564665447568744e626c326969697245564e536b4d656e334444727349483438567a515079416567726f395655747074774232545035484e633070347858786e456a66316d43366376366e6f344e4c6b6671517a7456654673535939616e6e716c6e612b6653766d704e71647a31494b3862474a34777352473976716b53344b2f75707364782f4366356a385253364e714a6a2b556e4b4e2b6c6446645730642f597957386f7a484b75445842514c4c5958636c6e50784a453244376a7366787230644b744f3359316f326c486c5a36506158547775737354593966513130396c7145563075507576335531353170756f5941566a785733484e305a472b6842357254415a6e57774d72627836722f4934635468464937624e4c5850326d7353494173337a723639785776446651546a354847665138477673734a6d6d47784b3932566e326535354e53684f47364c4e4649445335723054454b4b4b54496f4157696b7a78554574354443506e635a394279616970556854584e4e3251306d39455435714b61346968584d6a41653363316d5847724f334549326a315057737835586b596c6d4a4a366b6d76447865653034653751584d2b2f542f676e56547773706179304e4f34316a71496c78376e725754635854795a65567a676570717450644a426e63636e307249757279533462424f46394b2b5778654f72346c32715376356444307147455331534b4869574b4858744c6e302b59455179447176554873523731652b444f68332f6833544e55734c71344d6c71626e666172324359475778324a505566374e56696d635972766644467435476e6559657368342b677230736872566c58564744393356762b76754978394b6d6f632f5859334b4b4b4b2b3250464754494a49586a50526c4b6e386134386778735662677163477579505375613171333869374d672b354c7a2f774c76587a58456d4763715561386673757a39482f414d48387a74775537536358314d7963353656526b47474e57327146317a5878557058647a324b656736316b2f684a72503852364b313943743761726d36684851645a463950714f3157564a527130726558654f5078726f6f565846324364345335346e6e396c6542674d4774367a7632546a5046503133777930386a58326d41435938797739412f7550662b64633962585a44474f5146585867715267673131564b5561697645366f546a566a64486351586b6376422b552b74584559675a7a78374775526875656d4457684465756e527a394b3550656959564d50663454703472796550685a572b6d61744c716b34484c412f55567a6b6570482b4a5161734c66786e717048307273705a68577071305a7466656363384a336962333972546569666c5457314f636a71423942574d4c324c2f616f4e394542774361336562563376555a6e39565838706f795855736f2b65526a375a714c3643714231456677702b6456354c3656786a64676567726b7159745364336473316868356472476c4a5048454d73777a364373793431426d4745776f397171504a366d7172535a4e6338716b702b534f756e68347831593533796554544d35714d76543478765941416b6b344141366d68524f6a52497536665a7665336b554b446c6a2b51376d765349596c6868534a426855474257526f476b47776738325a6358456735483977656e31396132362b3379544c336871547156463730767758592b647832495657646f37494b4b4b4b39773451717071466f4c79316150675031516e73617430566e5670527177644f61756d4f4d6e4633527755675a484b7343724b63454874544d69756831335469366d3769584c4b5033674863657463307877612f4d3877774e54423133546c74306664487634657171734c6f63795a7045646f6d79446a464b7241696c494272687530622b544c3845367944673839785658564e43733957587a485879726744695a4238333050714b72674d68794d6972734e3967425a422b4972736f34684c53526a4b456f766d67636464365071656c4d576b6a4d3041365378636a38523146527758366e6a4e6568787a4b7779707a5653363058544c386c7037564e352f6a5435472f4d5632326a555263635931704e484c5233536e76566c6268665772372b443763484d46334f6e7334446634553065464a67634c664b5237782f2f587247574662324e76725646395372396f4148576e6565505772716546332f41493777663842542f7743765671507739614a393935704437746766705566564a45764530656a755a486d6a31705644794843497a4832476136474c54725745355342426a31476635314f7a4a474f5371696e39557372746d5478612b796a6e50374d764a657365776637624155372b784a53506d6e52665861704e6173326f5738663865397651566d58476f797a634435563942575575574f6b6452786e576e354935356e6b2f34534f50526b6a4c3345702f6476754156683148552f68786d76523944384e7861616f6d6e4b7a58583937487970395038613468394c68314b654e3233783345545a686e6a78766a623147515258714e7572706278724b356b6b565147636a473434354e6655354654773165382b58333432395056486e343670566a376a656a4a5252525258314a35595555555541464646464143455a466372726d6b47335a727133544d4a3564522f42372f542b566458534e6a427a58466a38425378744c6b6e76306659326f5670555a6330547a674848537056664e6257722b48324261347346794f7251662f452f34567a666d594f4f684855456369767a3347356657776b2b536f76523947652f53717772787645746b67303072554379314b73675065754678614e4c4e44777a716371784830717a4866544c7751472b7456647770636a7656526e4b4877736955564c6447694e525544356f7a2b427077314f502b34395a755236305a48725736786c56497a644342706e556b374931527471546337554834315133436d7339533856576c314255496469784a66544d5076342b6c55336b5a7a387a452f553031337146704b6a33706174334e6f775332484d525554483573564738774865744c51744b6b315735387877567455507a50362b777270772b4771567071464e5862484f63595263355051325044576c6d5268647972694e543867503841456638414156317452524b6b55617878714652526741646855674f612f517376774d4d4852564f4f2f563932664f56367a7254356d4c525252586359685252525141555555554146526e3171516a4e4d495070514245373446596572616661337838787759352f2b65716466784865747152474934552f6c5766635773726445632f6761797130616461484a5556305643636f506d69374d347535746269305968384f765a3036666a36564373766f6133723353373251485a424c30374961356937304c5834324c5731724f6659776b69766d385877326e3732486c386e2f6d6572537a507056587a5264576248656e6961735551654a6f2b4a6442753339346f322f6b522f576e71327235772b683671763841323579482b514e654a567962463039345035612f6b64304d54516e744a666b62486e65394c357739617a30683152782f794374514831744a422f4e616b4e7271662f514c762f38417747662f4141726c6542724c37442b343135716638792b38746d636574525063416436707951366b6f79644b31492f537a6c50386c716e4964587a694c772f72442b2f324e31483667567254797a4554656b4839784c725559377958336d67317a373158653578337167624c78544f635236446452413935596d503641442b64587248773772336d4235375734422f36354566307231734e7739586d37314c5258337334363259306f3651314e4454644d61376c5753374a6a6836374239357638425863326b6b6355537851717152714d4b716a67567a396a704e39474276676d48315131755731704d6f47593348315531395067384252776b6255317233366e6b3138524f733779324e4f4e39777159476f496f334856542b565467483072734d52344f525330555541464646464142525252514155555555414646464641425252525141555555554146464646414252525251415555555541464646464142525252514155555555414646464641482f2f5a


This is what I am using to recall the image BLOB

Code (gambas)

  1.     $Query &= "Select "
  2.     $Query &= "plulistid, "
  3.     $Query &= "Replace(Replace(description, ',,',','),'''','''') as description, "
  4.     $Query &= "barcodenumber, "
  5.     $Query &= "CAST(button_image AS CHAR) AS button_image, "    
  6.     $Query &= "button_number "
  7.     $Query &= "From plulist "
  8.     $Query &= "Where plulistid='" & Format(Val(PLUIDNumber), "0000") & "' "
  9.     $Query &= "order by button_number ASC;"

ANd yes the image is a small pic of a some bananas

When I run your code onm the string i have I get the following error message "Missmatch: Wanted Integer, Got Null instead"

I did convert your code to a Function

Code (gambas)

  1. Public Function ImageFromString(ImageString As String, ImageFile As PictureBox)
  2.  
  3. ' It starts from the 3rd numeric character, skipping the first two characters that are there to indicate that they are hexadecimal numbers (each pair of numeric characters represents an actual numeric value in hexadecimal format).
  4. ' It reads 2 numeric characters at a time, and therefore jumps by two numeric characters each time, to avoid reading a character at each cycle.
  5.   For c As Short = 2 To (ImageString.Len - 1) Step 2
  6. ' Converts the two numeric characters to the corresponding actual numeric value and then converts it to the corresponding ASCII string value. It assigns this string value to a string type variable, adding it to the other values already assigned:
  7.     t &= Chr(Val("&" & ImageString[c, 2]))
  8.   Next
  9.  
  10. ' It converts from the base64 string type and generates an Image type which is assigned to the "PictureBox":
  11.   ImageFile.Image = Image.FromString(FromBase64(t))  
  12.    
  13.  

did I convert your code wrong?
Online now: No Back to the top

Post

Posted
Rating:
#8
Regular
vuott is in the usergroup ‘Regular’

AndyGable said

I think I have a issue with the recall of the String from the database

When I recall the string I get

Code

"/9j/4AAQSkZJRgABAQEAYABgAAD......etc...."

it is not the same as what I have in the database

Code

0x2f396a2f344......etc.....
Yet, the string, attached by you, that you receive from the database, consists of correct string values, each corresponding with a byte-value of the image.
Basically, by my conversion loop, present in my code above, I get those real string characters.
In fact, for example, by converting the first two numeric characters "2" and "f" using my loop, we obtain the ASCII string character "/".

So, if I use this character string:

Code

"/9j/4AAQSkZJRgABAQEAYABgAAD......etc...."
I don't need to run the conversion loop, present in my code above.
In short, I can write:

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   Dim s As String = "/9j/4AAQSkZJRgABAQEAYABgAAD......etc....etc..."
  4.  
  5.   PictureBox1.Image = Image.FromString(FromBase64(s))
  6.  
…and again I see those two bananas in the PictureBox.


AndyGable said

This is what I am using to recall the image BLOB
Sorry, I can't help you here, as I never use database, and therefore know  :?  nothing about them.


AndyGable said

When I run your code onm the string i have I get the following error message "Missmatch: Wanted Integer, Got Null instead"
In which line of your function's code does the error message appear?

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#9
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

vuott said

AndyGable said

I think I have a issue with the recall of the String from the database

When I recall the string I get

Code

"/9j/4AAQSkZJRgABAQEAYABgAAD......etc...."

it is not the same as what I have in the database

Code

0x2f396a2f344......etc.....
Yet, the string, attached by you, that you receive from the database, consists of correct string values, each corresponding with a byte-value of the image.
Basically, by my conversion loop, present in my code above, I get those very string characters.
In fact, for example, by converting the first two numeric characters "2" and "f" using my loop, we obtain the ASCII string character "/".

So, if I use this character string:

Code

"/9j/4AAQSkZJRgABAQEAYABgAAD......etc...."
I don't need to run the conversion loop, present in my code above.
In short, I can write:

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   Dim s As String = "/9j/4AAQSkZJRgABAQEAYABgAAD......etc....etc..."
  4.  
  5.   PictureBox1.Image = Image.FromString(FromBase64(s))
  6.  
…and again I see those two bananas in the PictureBox.


AndyGable said

This is what I am using to recall the image BLOB
Sorry, I can't help you here, as I never use database, and therefore know  :?  nothing about them.


AndyGable said

When I run your code onm the string i have I get the following error message "Missmatch: Wanted Integer, Got Null instead"
In which line of your function's code does the error message appear?


Thank-you Thank-you Thank-you updating the way the function loads the image worked perfectly I can see the images now
Online now: No Back to the top

Post

Posted
Rating:
#10
Regular
vuott is in the usergroup ‘Regular’

AndyGable said

… updating the way the function loads the image worked perfectly ….
Ehmmm… practically… what did you do?

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#11
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
 Once you explain that what I was getting from the database was string data correctly formatted I just changed it to be

ImageFile.Image = Image.fromstring(frombase64(image string))
Online now: No Back to the top
1 guest and 0 members have just viewed this.