PDA

Click to See Complete Forum and Search --> : Picturebox Capers


Arbiter
Feb 17th, 2002, 01:10 PM
Guys,

I'm having problems with resizing images and displaying them.

I have the images stored in a picturebox, I resize them to another picture box using StretchBlt and they appear to lose colour depth.

This is irritating me.

Any ideas how I can get around this?

Thanks in advance...

Arbiter
Feb 17th, 2002, 01:29 PM
Additional:

The output of the resized picture is a 24 bit bitmap, so it's not losing the colour palette/depth.

In which case, there must be something wrong with the StretchBlt's resizing method.

Great.

Any ideas how to stop it maiming the image?

jenk
Feb 17th, 2002, 03:42 PM
Hi,
Just load the BMP into both picture boxs to set the palettes up
correctly, then imediatley after do your blitting...

could do this either with load picture (just to test) then try
picture1.picture=picture2.picture
blitstuff here

HTH.

Sastraxi
Feb 17th, 2002, 05:03 PM
Try passing different values to the SetStretchBltMode API call (or whatever its called ;)).

Arbiter
Feb 17th, 2002, 05:34 PM
Jenk,

Done that, the problem seems to lie with the stretchblt call.

Sas,

I'll have a look at it in more detail and post back.

Thanks guys.... :)

Arbiter
Feb 18th, 2002, 06:18 AM
Guys,

I've had a look at the call and I'm using it correctly. I've also had a look at loads of tutorials on it and they all use it the same way I have.

So why is the image seeming to lose colour depth? The image is still 24 bit, but it's cut down the number of used colours.

This is driving me crazy...

jenk
Feb 18th, 2002, 01:01 PM
Ok - this may be a long shot, but check out the StrechDIBits api.
This has a parameter for forcing the colour table palette.
(either RGB or PAL)

Its more complex to use but may solve your problem...

Arbiter
Feb 18th, 2002, 06:31 PM
Hmmmm..... The shot's so long, I need binoculars to see the end of it.

Well, as I'm too drunk to type any long words (or even see straight) I'll have a look at that idea tomorrow.

Cheers dude!

/\/\isanThr0p
Feb 21st, 2002, 10:20 AM
programming drunk is fun ...
the next day you only wonder about the wierd code you came up with
well basically don't do that to much, I hardly ever drink and if so I am normaly to tired to concentrate. (well maybe to drunk too :D )

Janus
Feb 21st, 2002, 09:22 PM
DIBits functions rule, but they suck for downsampling. to resize down you have to set the resizing mode properly... i forget which mode to use. You could always do a manual resize with GetDIBits and StretchDIBits, too.

Arbiter
Feb 24th, 2002, 01:40 AM
Goddamn!

I've just checked on this thread and realised that I'd utterly forgot about that last bit. This is what happens when you're drunk! :rolleyes:

I'm looking into that StretchDlBits thing now...

Arbiter
Feb 24th, 2002, 03:31 AM
Right,

I've had a look and it's confused the hell out of me.

What's the default StretchBltMode btw?

And that StretchDIBits just blew my head off my shoulders and halfway across the street.

Anyone got a good tutorial of the thing in action (preferably downsizing images)...?

Please? I'd love you forever....

Janus
Feb 24th, 2002, 10:26 AM
Yes, I have a number of examples, I'll try and throw together one for resizing...

Until then, check out this example from PSC:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=29762&lngWId=1

I wrote it a while back, it shows how to use GetDIBits and StretchDIBits. With enough smarts you could modify it to do manual downsampling. :)

I think the resampling mode you want is COLORONCOLOR, but I forget.

Arbiter
Feb 24th, 2002, 11:28 AM
Thankyou Janus.

I'll look at that now - greatly appreciated!

Arbiter
Mar 11th, 2002, 10:09 AM
Janus,

You'll be pleased to know I had a look at that.

Less pleased to know that I have absolutely no idea what's going on.

I'm crap at GDI stuff and the code in there is simply beyond me.

MY head hurts.... :(