UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
3 Pages V < 1 2 3  (Go to first unread post)
   Reply to this topicStart new topic
> Images To Hex VBA And Back, Access 2003    
 
   
patriciaxxx
post Oct 11 2016, 09:06 AM
Post#41



Posts: 273
Joined: 20-December 12



I’m ducking out too, think I should have a while back but thought someone may have had a solution.

I managed to find an image to base64 which loads the pictures I have correctly so I guess there wasn’t a problem with those or maybe there was (I haven’t had a response to the request of uploading those pics so I don’t know) anyway this base64 works for all images I have tried including those. It wasn’t the solution I was looking for as in this case I wasn’t looking to use a webbrowser control just standard controls but the idea did share some of what I was looking to do and I thought it was an interesting idea too.

I have also managed to code a function which gives me the hex and another which builds a string from that which I can then hardcode into a module. So I now have the ability to store a file within the code of a module in a database and not a table. As for using that code directly in controls without the need for any intermediary files being written to disk I believe it is not possible as was mentioned in an earlier post, although it has been suggested to me from someone far more experienced than me that it might be possible with some serious coding and api’s which is beyond my scope if indeed it is possible at all.

I’m sorry that some of you or all of you had such difficulty in understanding what I was trying to do. I would never have imagined that trying to find a second way of storing images in a database (that’s images and not image paths), the first being the binary field of a table, would have led to such confusion, especially among professionals. If I had known in advance I would have saved us all a lot of trouble and not posted the question but I genuinely found the concept of what I was trying to do as simple. The solution of course was not altogether clear to me but then that’s why I posted the question.

I am grateful for any help I receive to questions which I post, and would like to thank everyone for trying to assist me here and too to make it clear that it is very much appreciated.
Go to the top of the page
 
cheekybuddha
post Oct 11 2016, 11:13 AM
Post#42


UtterAccess Moderator
Posts: 12,620
Joined: 6-December 03
From: Telegraph Hill


Hi,

Apologies for taking so long to get back.

Thanks for posting the images - they worked fine for me.

The bmp was larger than the size of the web browser control, so you had to scroll down to see the bottom of it.

This is easily dealt with by adjusting the CSS in the web page written.

Try changing the fLoadImg() function to:
CODE
Function fLoadImg(xWebCtl As Object, strImgPath As String) As Boolean

  Dim strHTML As String
  
  strHTML = "  <head>" & vbNewLine & _
            "    <style type='text/CSS'>" & vbNewLine & _
            "      html, body { max-height: 100%; }" & vbNewLine & _
            "      div { width:100%; height:100%; display:inline-block; position:relative; overflow:hidden; background-color: #eff0f1; }" & vbNewLine & _
            "      img { max-width:100%; max-height:100%; width:auto; height:auto; position:absolute; top:0; bottom:0; left:0; right:0; margin:auto }" & vbNewLine & _
            "    </style>" & vbNewLine & _
            "  </head>" & vbNewLine
  strHTML = strHTML & _
            "  <body>" & vbNewLine & _
            "    <div>" & vbNewLine & _
            "      <img id='myImg' src='" & strImgPath & "' />" & vbNewLine & _
            "    </div>" & vbNewLine & _
            "  </body>" & vbNewLine

  strHTML = "<html>" & vbNewLine & _
            strHTML & _
            "</html>"

  With xWebCtl
    .Navigate "about:blank"
    Call fWaitComplete(.Object)
    If Len(strHTML) Then
      .Document.Write strHTML
      Call fWaitComplete(.Object)
    End If
  End With

End Function


You can get the Base64 representation of the image using the TestIt() function which you can then hardcode as a constant in a module (you may have to use a good text editor to add in double quotes and line continuation characters).

I'm sorry this thread degenerated the way it did. I can see plenty of reasons why you may wish to encode an image this way (portability, security through compiling, passing/receiving to/from a web service, etc etc), but in the end simply why not if that's what you want to do.

I'm glad you seem to have found a solution - continued success with your project.

thumbup.gif

d
Go to the top of the page
 
patriciaxxx
post Oct 13 2016, 05:08 AM
Post#43



Posts: 273
Joined: 20-December 12



That’s very kind of you David and much appreciated.
Thank you.
Go to the top of the page
 
cheekybuddha
post Oct 13 2016, 05:34 AM
Post#44


UtterAccess Moderator
Posts: 12,620
Joined: 6-December 03
From: Telegraph Hill


yw.gif
Go to the top of the page
 
sifar786
post Feb 15 2020, 01:55 AM
Post#45



Posts: 25
Joined: 19-July 10



Old post, but worth commenting....

I think what @Patricia meant by `Module` was a `Class Module`to store the Hex data into some variables or collections and then reuse it whenever required, without recreating a Physical file on disk - as long as the MSAccess or MSExcel (session) was open.

Right now, i am searching for such a Class Module to store images in Excel.
This post has been edited by sifar786: Feb 15 2020, 01:57 AM
Go to the top of the page
 
sifar786
post Feb 15 2020, 05:17 AM
Post#46



Posts: 25
Joined: 19-July 10



But the only problem is, even if i store HEX data as an Array to a Custom Class for later retrieval, how do i insert the image once i reconvert the HEX data into an image - because the converting the HEX data requires the generated binary to be saved as a file to a location on the disk and cannot be inserted directly as a picture into an Excel Worksheet cell?

Better way is to instead create a Custom Class that can store the images directly to a collection or dictionary instead of converting them to HEX data. This way, hopefully the pictures could be inserted into the worksheet cells whenever required. Is this not so? OR am i going wrong here?
Go to the top of the page
 
3 Pages V < 1 2 3


Custom Search


RSSSearch   Top   Lo-Fi    5th April 2020 - 01:50 AM