Dimensions on gif / jpg 
Author Message
 Dimensions on gif / jpg

Hi All !

I am trying to get the dimensions of "*.jpg" and "*.gif" - files.

There have to be a better solution than cheating by preloading it into a
hidden PicBox & read it from there....

I got bitmaps(*.bmp) right, by sending a BITMAP to GetObjectAPI, but I don't
have a
clue with the other filetypes.

Any help appreciated??

Thanks, Per Rollvang



Fri, 19 Apr 2002 03:00:00 GMT  
 Dimensions on gif / jpg
You can probably read it right out of the file headers, but I'm not
intimately familiar with these file formats myself.  Look 'em up at
www.wotsit.org

Jim Deutch
MS Dev MVP

Quote:

>Hi All !

>I am trying to get the dimensions of "*.jpg" and "*.gif" - files.

>There have to be a better solution than cheating by preloading it into a
>hidden PicBox & read it from there....

>I got bitmaps(*.bmp) right, by sending a BITMAP to GetObjectAPI, but I
don't
>have a
>clue with the other filetypes.

>Any help appreciated??

>Thanks, Per Rollvang




Sat, 20 Apr 2002 03:00:00 GMT  
 Dimensions on gif / jpg
Thanks Jim

Per Rollvang




Sun, 21 Apr 2002 03:00:00 GMT  
 Dimensions on gif / jpg


Quote:
>Hi All !

>I am trying to get the dimensions of "*.jpg" and "*.gif" - files.

>There have to be a better solution than cheating by preloading it into a
>hidden PicBox & read it from there....

>I got bitmaps(*.bmp) right, by sending a BITMAP to GetObjectAPI, but I don't

Help for LoadPicture Function:
"Graphics formats recognized by Visual Basic include bitmap (.bmp)
files, icon (.ico) files, cursor (.cur) files, run-length encoded (.rle)
files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif)
files, and JPEG (.jpg) files."

  Dim xpixels As Long, ypixels As Long
  Dim filename As String
  Dim APicture As Picture

  filename = "whatever"

  Set Apicture = LoadPicture(filename)

  xpixels = Me.ScaleX(APicture.Width, vbHimetric, vbPixels)
  ypixels = Me.ScaleY(APicture.Height, vbHimetric, vbPixels)

  Set Apicture = Nothing

Getting the dimensions of jpg and gif directly from the disk file is
nightmarish, and just not worth the effort when you can use the above
code.

--
Richard Mason



Sun, 21 Apr 2002 03:00:00 GMT  
 Dimensions on gif / jpg
Thanks Richard !

This is pretty much what I was looking for. The only drawback is that I will
use this code with a usercontrol-object, and I have to implement the
FileOpen-Dialog in there too, because the UserControl provide the dialog,
but return only hPicture.

The other possible solution I wonder .. is it possible to load the gif / jpg
into a memoryDC? What do you search for with GetObjectAPI, is this possible
at all ??

Thanks


Quote:


> >Hi All !

> >I am trying to get the dimensions of "*.jpg" and "*.gif" - files.

> >There have to be a better solution than cheating by preloading it into a
> >hidden PicBox & read it from there....

> >I got bitmaps(*.bmp) right, by sending a BITMAP to GetObjectAPI, but I
don't

> Help for LoadPicture Function:
> "Graphics formats recognized by Visual Basic include bitmap (.bmp)
> files, icon (.ico) files, cursor (.cur) files, run-length encoded (.rle)
> files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif)
> files, and JPEG (.jpg) files."

>   Dim xpixels As Long, ypixels As Long
>   Dim filename As String
>   Dim APicture As Picture

>   filename = "whatever"

>   Set Apicture = LoadPicture(filename)

>   xpixels = Me.ScaleX(APicture.Width, vbHimetric, vbPixels)
>   ypixels = Me.ScaleY(APicture.Height, vbHimetric, vbPixels)

>   Set Apicture = Nothing

> Getting the dimensions of jpg and gif directly from the disk file is
> nightmarish, and just not worth the effort when you can use the above
> code.

> --
> Richard Mason



Mon, 22 Apr 2002 03:00:00 GMT  
 Dimensions on gif / jpg


Quote:
>Thanks Richard !

>This is pretty much what I was looking for. The only drawback is that I will
>use this code with a usercontrol-object, and I have to implement the
>FileOpen-Dialog in there too, because the UserControl provide the dialog,
>but return only hPicture.

You've lost me here.

Quote:
>The other possible solution I wonder .. is it possible to load the gif / jpg
>into a memoryDC? What do you search for with GetObjectAPI, is this possible
>at all ??

I'm not sure if this is what you mean.

Using the same code:

  Set Apicture = LoadPicture(filename)

  xpixels = Me.ScaleX(APicture.Width, vbHimetric, vbPixels)
  ypixels = Me.ScaleY(APicture.Height, vbHimetric, vbPixels)

'Select into a DC
  'selecting into a memory DC
  hdcNew = CreateCompatibleDC(0&)
  hbmpOld = SelectObject(hdcNew, APicture.Handle)

'Use GetObjectAPI
  Dim bmap As BITMAP
  lret = GetObjectAPI(APicture.Handle, Len(bmap), bmap)

If one doesn't want to use the ScaleX/Y function then Himetric to Pixels
can be directly calculated.

--
Richard Mason



Tue, 23 Apr 2002 03:00:00 GMT  
 Dimensions on gif / jpg
Hi Richard  !

I must admit I lost myself here.. My problem was really just to get rid of
that picturebox. You have already given me a clear answer to that one.
Please just pretend I did not post that last one. Sorry !!


Quote:


> >Thanks Richard !

> >This is pretty much what I was looking for. The only drawback is that I
will
> >use this code with a usercontrol-object, and I have to implement the
> >FileOpen-Dialog in there too, because the UserControl provide the dialog,
> >but return only hPicture.

> You've lost me here.

> >The other possible solution I wonder .. is it possible to load the gif /
jpg
> >into a memoryDC? What do you search for with GetObjectAPI, is this
possible
> >at all ??

> I'm not sure if this is what you mean.

> Using the same code:

>   Set Apicture = LoadPicture(filename)

>   xpixels = Me.ScaleX(APicture.Width, vbHimetric, vbPixels)
>   ypixels = Me.ScaleY(APicture.Height, vbHimetric, vbPixels)

> 'Select into a DC
>   'selecting into a memory DC
>   hdcNew = CreateCompatibleDC(0&)
>   hbmpOld = SelectObject(hdcNew, APicture.Handle)

> 'Use GetObjectAPI
>   Dim bmap As BITMAP
>   lret = GetObjectAPI(APicture.Handle, Len(bmap), bmap)

> If one doesn't want to use the ScaleX/Y function then Himetric to Pixels
> can be directly calculated.

> --
> Richard Mason



Tue, 23 Apr 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Dimensions of GIF and JPG from files

2. Dimensions of GIF and JPG from files

3. .bmp, .gif, .jpg dimensions

4. ? How to get dimensions of gif or jpg

5. Using VBA in A2k to get dimensions of a jpg file

6. jpg file dimension retrieval

7. Jpg File Dimensions / Html

8. Help! - jpg file dimensions

9. jpg file dimension retrieval

10. Tip: Reading the image dimensions of a GIF file

11. Any way to read JPG & GIF picture dimensions using QBASIC???????????????????????

12. Dimensions of JPG's & GIF's

 

 
Powered by phpBB® Forum Software