Solved

Picture / Object size

Posted on 2000-04-17
6
188 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:scj1
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now