Solved

Picture / Object size

Posted on 2000-04-17
6
191 Views
Last Modified: 2013-11-26
I need to use the AppendChunk/GetChunk methods with an ADO recordset. The example in the MSDN uses the ActualSize property to get the object size but I want to put a picture from a file (via loadpicture). I basically need to find out the object size in order to break it into chucks for the append and get chunk methods.

By object size - I DON'T mean width or height, I mean the byte size in total.

Thanks,

StuJ
0
Comment
Question by:scj1
  • 3
  • 2
6 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 2722692
Check the filesize, this will give you the answer

    Dim lngFileSize As Long
    Open "Picture.bmp" For Binary Access Read As #1
    lngFileSize = LOF(1)
    Close #1
    MsgBox lngFileSize
0
 
LVL 1

Author Comment

by:scj1
ID: 2722742
Ok, I have though of this but that will only help if the picture is a bitmap file. Is there a way of getting the size from the object reference?

Thanks.
0
 
LVL 1

Expert Comment

by:Ask_ED
ID: 2722853
Hi,

Tim's got the right idea and it isn't limited to only bitmaps any file type (GIF/TIF/JPG..etc) can be sized that way... but I'd recommend using the FileLen function instead.

msgbox FileLen(pathname)

If you use the FileLen function, you do not have to explicitly "open" then file, thereby eliminating that overhead.

Hope this helps
ED
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 1

Author Comment

by:scj1
ID: 2723132
The point here though, I realise that the file length, however you get it, will return the filesize. However, I wasn't planning on storing the file but rather the file contents. Thus, if a jpeg or compressed gif/bmp/etc. is used, the ipicturedisp object will generally be the same despite differing file sizes (lossy compressed files excepted from this rule).
0
 
LVL 1

Accepted Solution

by:
Ask_ED earned 100 total points
ID: 2723366
Hi Again,

Isn't your goal to find the ammount of data you need to append to the database ???

Knowning the size in memory of the 'object' isn't going to help you append to the database.

Unless you have a high-end graphics control or class you are still going to have to save the image back to the disk before appending it to the database, so the important value is the file size and the object size is a "nice to know", but not required bit of data.


Am I missing something here ?

Bye for Now
ED
0
 
LVL 1

Author Comment

by:scj1
ID: 2747891
I've actually solved the problem now and as you rightly said, I did need to save the object to disk before I could right it to the database. This does, however, seem a bit of a wasteful way of doing things - wouldn't it be better if I could just put the object in memory to the database rather than through a broken up file. After all, what is the image datatype for otherwise?

Cheers,

Stuart
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question