Solved

Picture / Object size

Posted on 2000-04-17
6
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month8 days, 16 hours left to enroll

617 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