|
-
December 10th, 1999, 05:39 PM
#1
StretchBits
I am trying to use StretchBits to fit an image to a picture box whose size is much smaller than the original image size. I am using StretchBits. It's displaying the image smaller, however it's messing up the colors. What's the correct way to fit an image to a smaller picture box?
BTW, I am using in-house developed C functions to load the image into the memory and to get a handle to it since my image formats can be PPM, TIF,JPG, PGM,BMP.
Please advise.
My code looks like:
If (bmpDC <> 0) then
resp = DeleteDC(bmpDC)
End If
if (mhBmp <> 0) then
resp = DeleteObject(mhBmp)
End If
Form1.Picture2(0).AutoRedraw = true
i3 = loadImage(fname, imageP, Form1.Picture2(0).hDC, 0) ' MY DLL
mhBmp = GetBMP(imageP, Form1.Picture2(0).hDC, 1, 1) 'MY DLL
If (mhBmp = 0) then
resp = MsgBox("Could not create a BITMAP", 0, "error")
Exit Sub
End If
Form1.Picture2(0).Picture = LoadPicture()
mHdc = Form1.Picture2(0).hDC
If mhBmp <> 0 then
bmpDC = CreateCompatibleDC(Form1.Picture2(0).hDC)
saveDC = SelectObject(bmpDC, mhBmp)
ratio = imageP.col / imageP.row
i3 = StretchBlt(Form1.Picture2(0).hDC, 0, 0, Form1.Picture2(0).ScaleWidth * ratio, Form1.Picture2(0).ScaleWidth, bmpDC, 0, 0, imageP.col, imageP.row, SRCCOPY)
end if
Form1.Picture2(0).refresh
&
Pinar
-
December 11th, 1999, 06:18 AM
#2
Re: StretchBits
1) If you're running in 256-color display mode, load as DIB or DIB section, create palette, and use the palette to display the bitmap.
2) Use HALFTONE stretch mode for better color bitmap display during stretching.
-
December 15th, 1999, 06:30 PM
#3
Re: StretchBits
Thanks for the tip for using HALFTONE. I instead used COLORONCOLOR and it worked
perfect.
Thanks again.
&
Pinar
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|