PDA

View Full Version : Problems with displaying resource



rbrunton
08-02-2004, 09:14 AM
Greetings,

I have been trying to display a graphic from a resource without enough success.
I've tried two approaches. The first attempts to read a JPEG image as a resource. I have follwed the example in HELP and the TIPS section of the site. Two problems arize, one of which I think is just a typo. That is with the function IS3ReadJPG. In the example the line is HGLOBAL hRGB = IS3ReadJPG(hSrc, &uW, &uH, 24, NULL, 0); and I receive the error message that IS3ReadJPG doesn't take 6 parameters. The ImgSource documentation supports that indicating only five.

When I use the function with only five parameters (HGLOBAL hRGB = IS3ReadJPG(hSrc, &uW, &uH, 24, 0);) I receive an error code 9 (incorrect format). I'm assuming that my problem here is that I haven't imported the JPEG properly as a resouce. In VC.NET I right-click on the resource editor page and choose "Add Resource" and then "Import". I am allowed to import the JPEG file and am asked to identify the type of resource. I type JPEG and it is displayed as "JPEG" (with quotes) and the resource ID is IDR_JPEG1. I then use the line
if (hRsrc = FindResource(hInstance, MAKEINTRESOURCE(IDR_JPEG1), "JPEG")) ...

All of this executes properly until the read statement at which point hRGB is returned as a NULL value.

The second approach is to import the resource as a BITMAP. I can then display it, but I haven't been able to resize it to fit the available window. In order to do that it appears that I need to convert it to a DIB, but that has also eluded me.

Any help with either approach would be greatly appreciated.

Ron

Chris
08-02-2004, 09:41 AM
>When I use the function with only five parameters (HGLOBAL hRGB =
>IS3ReadJPG(hSrc, &uW, &uH, 24, 0);) I receive an error code 9
>(incorrect format). I'm assuming that my problem here is that I
>haven't imported the JPEG properly as a resouce.

it's also possible that the file you've imported really isn't a JPG.

just as an experiement, try using IS3ReadImageToRGB, to let ImgSource handle guessing the file type.

>The second approach is to import the resource as a BITMAP. I can then
>display it, but I haven't been able to resize it to fit the available
>window. In order to do that it appears that I need to convert it to a
>DIB, but that has also eluded me.

you can use IS3HBITMAPToRGB to create an RGB copy of that HBITMAP. then you can resize it, etc..

-c

--
chris losinger
smallest@smalleranimals.com

guest
08-02-2004, 10:27 AM
The first option works perfectly. Many thanks Chris, both for the content and the timeliness of your response. It would be spectacular if every business had customer support like yours! :-)