Resizing Pictures in Form Resize and Multiple Resolutions

GabryJ
01-14-2005, 06:58 AM
Hi, i have an application in which i have a picture box. the form is resizable, so the picturebox is supposed to resize too.

Is there an api or a property or control that lets me resize also the loaded picture, without bloating application resource size with adding multiple pictures of the same picture?

SteRobson
01-14-2005, 07:09 AM
Is there an api or a property or control that lets me resize also the loaded picture, without bloating application resource size with adding multiple pictures of the same picture?

You could use the paintpicture method of the picture box, or for an API method use StretchBlt. With a bit of work either of these methods could do what you're asking.

GabryJ
01-14-2005, 09:09 AM
You could use the paintpicture method of the picture box, or for an API method use StretchBlt. With a bit of work either of these methods could do what you're asking.

Do you have some working examples for the PaintPicture method? Maybe i'm wrong but it does not seem to work on xp sp2.

OnErr0r
01-14-2005, 10:41 AM
1) Resize the picturebox in the form_resize event.

2) Call PaintPicture in the picturebox_resize event.

PaintPicture (http://msdn.microsoft.com/library/en-us/vb98/html/vbmthPaintPicture.asp) will work fine regardless of the OS.

GabryJ
01-14-2005, 08:11 PM
OK, thanks to all for help. Now i succedeed and eveything works as expected. I have one more question:

I want to have all my bitmaps stored in a resouce file in a dll and then load pictures from program calling them from the dll with LoadResPicture or similar.

If possible i'd rather avoid putting them in a form and calling pictures like form1.picture1.picture = dllbmp.form1.picture1.picture like newbies do.

Is there a way with loadrespicture or any other form of smart programming?

zelg37
01-15-2005, 12:37 AM
I have one more question:
I want to have all my bitmaps stored in a resouce file in a dll and then load pictures from program calling them from the dll with LoadResPicture or similar
See the section "Using Resources Located in an External DLL File" at the bottom of this page:
http://www.thevbzone.com/l_res.htm

OnErr0r
01-15-2005, 02:18 AM
OK, thanks to all for help. Now i succedeed and eveything works as expected. I have one more question:

I want to have all my bitmaps stored in a resouce file in a dll and then load pictures from program calling them from the dll with LoadResPicture or similar.

If possible i'd rather avoid putting them in a form and calling pictures like form1.picture1.picture = dllbmp.form1.picture1.picture like newbies do.

Is there a way with loadrespicture or any other form of smart programming?

Yes, you can use a resource file to contain your images. In fact, you can even use compressed formats like JPG or GIF to save space. LoadResPicture will work well for uncompressed images like BMP or ICO. You will need to have an accessor function which returns StdPicture inside the dll, and takes a resourceID and image type parameters. For instance:

Public Function LoadDllPicture(ByVal lResID As Long, ByVal eResType As ResourceType) As StdPicture

Within that function you call either LoadResPicture, or LoadResData for compressed formats. You'll also want my PictureFromRes function located here: http://www.visualbasicforum.com/showpost.php?p=495265&postcount=3

Set LoadDllPicture = PictureFromRes(LoadResData(lResID, "CUSTOM"))

Note: There is no reason to use any API calls to access resources within your resource dll. I only use APIs to convert stored JPG or GIF to IPicture (same as StdPicture).

GabryJ
01-15-2005, 10:18 AM
Do you know if it works on all os? (Mean 95, NT4, 98, Me, 2000 and XP)? Do i have to include something in the installation routine?

OnErr0r
01-15-2005, 11:56 AM
All 32bit OSes, yes. No. Well.. aside from your dll, of course. ;)

You could also put your resources in your EXE, which would not require any external files.

GabryJ
01-15-2005, 12:02 PM
All 32bit OSes, yes. No. Well.. aside from your dll, of course. ;)

You could also put your resources in your EXE, which would not require any external files.

In fact it is what I did. Previously when i had bitmaps and the whole executable was over 20 Megs it made sense to build up a dll, now with jpegs the exe is nearly 3 megs so it does not make sense to overwork.

Thank you very much. I will put you in the thanks to in my application about or help file. ;)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum