locked
find file size of a bitmap object? RRS feed

  • Question

  • User-1438894470 posted

     Hey all.

    I have an image file, which I load into my application, and create a bitmap object with it, but changing teh width/height. Is there anyway I can find out how much the filesize would be for this when it gets saved, without actually saving it at this point?

    Basically, with resizing, I want to show the new width/height which is easy enough, but also what the filesize would be for saving teh image. Then if the user decides to save they can do so.

    Thanks, Paul.

    Friday, May 15, 2009 8:43 AM

All replies

  • User-18289217 posted

     Can't you read the bytes of the new bitmap?

    Friday, May 15, 2009 10:47 AM
  • User-1438894470 posted

     whats the gbest way to do that?

    When creating the file, I will be doing

     newBMP.Save(strFilename, ifExt)

     where ifEXT is the imageformat (i.e. .jpg or .gif etc etc), so any size I get to would need to mirror what that would save as.

    Friday, May 15, 2009 11:12 AM
  • User-196746684 posted

    2 ways to do it

    1) call a component like Leadtools

    2)  System.Drawing.Image

    				Dim _leadctrl As New LEADLib.LEAD
    				_leadctrl.GetFileInfo(LocalPath, 0, 0)
    				PicHeight = _leadctrl.InfoHeight
    				PicWidth = _leadctrl.InfoWidth
    				_leadctrl = Nothing
    
    
    
    				'Dim fullSizeImg As System.Drawing.Image
    				'fullSizeImg = System.Drawing.Image.FromFile(LocalPath)
    				'PicHeight = fullSizeImg.Height
    				'PicWidth = fullSizeImg.Width
    				'fullSizeImg.Dispose()
    
     
    Thursday, June 4, 2009 8:43 AM
  • User-1438894470 posted

     that code still only gets me the height and width which I already know. It doesnt get me the size. I need a way to get the size without saving. The reason for this is the user can resize the image using a scroll bar type button..which will constantly change the size as it goes.

    Thursday, June 4, 2009 4:38 PM