|
-
Sep 24th, 2000, 04:01 PM
#1
Thread Starter
Hyperactive Member
How is picture stored?
What type of field do you use for the picture? Since it's Access, I will assume it is OLE Object which will resolve in VB terms to a Field object of type adLongVarBinary.
IN other lanuages this would be called a BLOB (but tha't not important right now - hehe).
I have posted a method from one of my apps which does something similar to what you want. Beware that this code will not function as is - it is provided for you to get soe ideas only.
The important bits are:
1) Size an array of byte to either a specific chunk size or like in my case, directly to the size of the BLOB. (In my case I am certain that the Access DB will only contain JPG's less that 50KB)
2) retrive the chunk(s) from the BLOB and dump them to disk
3) Now treat the dumped file anyhow you like.
Code:
Function ReadDIBField(fld As ADODB.Field) As cDIBSection
Dim picDIB As New cDIBSection
On Error GoTo err_read
Dim myvar As Variant
Dim tmpFile As String
Dim mSize As Long
mSize = fld.ActualSize
ReDim bits(mSize - 1) As Byte
myvar = fld.GetChunk(mSize)
bits = myvar
If mySettings Is Nothing Then
tmpFile = "c:\test.pic"
Else
tmpFile = mySettings.InternalTempFile
End If
'now put the file to disk and loadJPG it
Dim f As Long
f = FreeFile
' wipe the tmp file
On Error Resume Next
Kill tmpFile
On Error GoTo err_read
Open tmpFile For Binary As #f
Put #f, , bits
Close #f
' load the file (it was a JPG in the DB)
LoadJPG picDIB, tmpFile
Set ReadDIBField = picDIB
Exit Function
err_read:
' to make sure the cdibsection has a chance to free
Set ReadDIBField = Nothing
End Function
I believe there is enough in there to get you started.
Regards
-
Sep 24th, 2000, 04:08 PM
#2
_______
<?>
I simply use the mdb to store the filename and description and then I store the file in the app folder and call it from there. From what I hear the storing in an mdb is quite heavy on processing. I can't say that it is any worse, I've heard it was.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 24th, 2000, 05:32 PM
#3
Thread Starter
Hyperactive Member
Sometimes you have to live with heavy processing
Sometimes it is more important to have the data contained in one place rather than in several places. If the files were separate from the database then several problems could occur if the images on the server were renamed / deleted / deliberately altered etc.
Furthermore, if the application ever needed to be scaled onto Oracle or SQL Server, by encapsulating the images in a field in a DB table, you are able to migrate far easier.
For most home user applications however, it would indeed be easier/faster/better (in many cases) to do as HeSaidJoe suggests.
My two cents worth 
Cheers
-
Sep 24th, 2000, 05:48 PM
#4
_______
<?>
There is a lot of value in those 2 cents...
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 24th, 2000, 06:34 PM
#5
Thread Starter
Hyperactive Member
Thanks
I don't normally chit chat, but I can't help myself in this case because after I wrote "my two cents worth", I remembered that several years ago my country did away with our one and two cent coins.
So nowadays, it should be "my five cents worth".
But if I ponder too long on the origin of the phrase, I might wonder whether it was originally "two bits worth" which funnily enough has some bearing in the programming world as well 
Ahh, the ravings of an idle mind...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|