1 Attachment(s)
[VB6] - stretch an image to usercontrol size
i have 1 line for stretch 1 image in Usercontrol(by it size). but the width isn't correct:(
Code:
StretchBlt UserControl.hDC, 0, 0, UserControl.Width \ Screen.TwipsPerPixelX, UserControl.Height \ Screen.TwipsPerPixelY, PicAnimation(lngActualSubImage).hDC, 0, 0, PicAnimation(lngActualSubImage).Width, PicAnimation(lngActualSubImage).Height, vbSrcCopy
(see the image for see the bug)
what isn't correct?
Re: [VB6] - stretch an image to usercontrol size
Your screen shot does not help exactly. We do not know what the source looks like.
You are using PicAnimation(...).Width & PicAnimation(...).Height. Those measurements are in the scalemode of the container where the PicAnimation control resides. If not vbPixels, ensure you convert to pixels. If the PicAnimation controls have borders, suggest not using Width,Height but use ScaleWidth,ScaleHeight
Re: [VB6] - stretch an image to usercontrol size
Quote:
Originally Posted by
LaVolpe
Your screen shot does not help exactly. We do not know what the source looks like.
You are using PicAnimation(...).Width & PicAnimation(...).Height. Those measurements are in the scalemode of the container where the PicAnimation control resides. If not vbPixels, ensure you convert to pixels. If the PicAnimation controls have borders, suggest not using Width,Height but use ScaleWidth,ScaleHeight
everything is in pixels, autoredraw is true and the border is none. and i try use the scale size, but the results are the same(except being big, is small. but tell me 1 thing if i use the control size(see the blue points), why the image have a diferent size?
Re: [VB6] - stretch an image to usercontrol size
for resulve the problem i use const values(like convert something):
Code:
StretchBlt UserControl.hDC, 0, 0, UserControl.ScaleWidth * (Screen.TwipsPerPixelX - 9), UserControl.ScaleHeight * (Screen.TwipsPerPixelY - 12), PicAnimation(lngActualSubImage).hDC, 0, 0, PicAnimation(lngActualSubImage).ScaleWidth, PicAnimation(lngActualSubImage).ScaleHeight, vbSrcCopy
maybe using the last line(in 1st post) with these combination, the problem can be resolved;)
but, please, tell me what you think.
Re: [VB6] - stretch an image to usercontrol size
I think it is not a good idea to hardcode some constants. You are not getting the correct result because of something else. To answer your question in post #3, I can't tell you unless you show us the source picturebox with the image in it.
Re: [VB6] - stretch an image to usercontrol size
Quote:
Originally Posted by
LaVolpe
I think it is not a good idea to hardcode some constants. You are not getting the correct result because of something else. To answer your question in post #3, I can't tell you unless you show us the source picturebox with the image in it.
ok.. heres i put the image in uc:
Code:
UserControl.Picture = PicAnimation(lngActualSubImage).Image
the picanimation() is for recive the image\subtimage original. then i use the if's for do the effects:
Code:
If blnStretch = True Then
StretchBlt UserControl.hDC, 0, 0, UserControl.ScaleWidth * (Screen.TwipsPerPixelX - 9), UserControl.ScaleHeight * (Screen.TwipsPerPixelY - 12), UserControl.hDC, 0, 0, PicAnimation(lngActualSubImage).ScaleWidth, PicAnimation(lngActualSubImage).ScaleHeight, vbSrcCopy
UserControl.Picture = UserControl.Image
End If
but. like you said, can give some bad resultes... and i recive bad image results in some images:(
what you need to know more?
or i can put here a link(because i don't have space in my attachment file:() and show you my work(entire project).. just say it
Re: [VB6] - stretch an image to usercontrol size
i can show the image\subimage, without a problem, in autosize true(because without these effect the animation\static works normaly). my problem is try to sretch the image.
Re: [VB6] - stretch an image to usercontrol size
1 big question: if my uc is in pixel and the form is in pixel, why the size is diferent?
inside of uc: the width is 690;
in form: the width is 46.
now tell me something?
(i debug these for see the results)
or i must use the api function?
Re: [VB6] - stretch an image to usercontrol size
UserControl.Width,Height are always in Twips: 690 in your case. Same as a form's Width,Height are always in Twips.
UserControl.ScaleWidth,ScaleHeight are in usercontrol's ScaleMode: 46 in your case
In post #2 above I tried to explain that to you. A control's Width,Height values are always in the control's container's scalemode. So UserControl1.Width will be in the uc's container's scalemode. UserControl1.Width is not the same as UserControl.Width called from within the uc.
Re: [VB6] - stretch an image to usercontrol size
Quote:
Originally Posted by
LaVolpe
UserControl.Width,Height are always in Twips: 690 in your case. Same as a form's Width,Height are always in Twips.
UserControl.ScaleWidth,ScaleHeight are in usercontrol's ScaleMode: 46 in your case
In post #2 above I tried to explain that to you. A control's Width,Height values are always in the control's container's scalemode. So UserControl1.Width will be in the uc's container's scalemode. UserControl1.Width is not the same as UserControl.Width called from within the uc.
ok. i understand that. but now i still have the same question: why that width(in these case) bug?
Re: [VB6] - stretch an image to usercontrol size
......... i'm still blocked:(
Re: [VB6] - stretch an image to usercontrol size
i'm good hehehehe
i found the solution:
1 - i have 1 picturebox for catch the real image size and works 100% fine;
2 . i use the Extender object for catch the actual usercontrol size and works fine.
Code:
If blnStretch = True Then
StretchBlt UserControl.hDC, 0, 0, Extender.Width, Extender.Height, UserControl.hDC, 0, 0, imgSize.Width, imgSize.Height, vbSrcCopy
UserControl.Picture = UserControl.Image
End If
my little problem is if i reduze the original size(in UC) the image is showed like a double in diferent size. i belive that is something that i forget in that IF. can you advice me more?
Re: [VB6] - stretch an image to usercontrol size
ok... heres the code for avoid the double image;):
Code:
If blnStretch = True Then
picGraphicsEffects.Width = Extender.Width
picGraphicsEffects.Height = Extender.Height
picGraphicsEffects.Picture = Nothing
StretchBlt picGraphicsEffects.hDC, 0, 0, Extender.Width, Extender.Height, UserControl.hDC, 0, 0, imgSize.Width, imgSize.Height, vbSrcCopy
UserControl.Picture = Nothing
picGraphicsEffects.Picture = picGraphicsEffects.Image
UserControl.Picture = picGraphicsEffects.Image
End If
but when i reduse de image(from original size), i recive 1 bug. in image the half(more or less) image isn't showed. why? is about the stretchblt bug?
Re: [VB6] - stretch an image to usercontrol size
There is no stretchblt bug I'm aware of. If you can show us a screenshot of the source picturebox with its image and then the result so we can better understand what the problem is, we might be able to offer more advice
1 Attachment(s)
Re: [VB6] - stretch an image to usercontrol size
Quote:
Originally Posted by
LaVolpe
There is no stretchblt bug I'm aware of. If you can show us a screenshot of the source picturebox with its image and then the result so we can better understand what the problem is, we might be able to offer more advice
see the image. these bug only happens when the size is less than original
Re: [VB6] - stretch an image to usercontrol size
If your source and destination picboxes are not the same size ratios then your image will appear to be stretched horizontally or vertically vs scaled. If your source picbox contains a bunch of blank space around the image, then the destination picbox will contain that extra space also when you StretchBlt.
If you need to just blt the area around the source image, excluding any extra space, you will have to calculate a tight rectangle around the image and just StretchBlt that rectangle's dimensions.
Regarding size ratios: If (sourceWidth/destWidth) <> (sourceHeight/destHeight) then you will not get a scaled rendering and you will have to determine what horizontal/vertical ratios to use.
Re: [VB6] - stretch an image to usercontrol size
Quote:
Originally Posted by
LaVolpe
If your source and destination picboxes are not the same size ratios then your image will appear to be stretched horizontally or vertically vs scaled. If your source picbox contains a bunch of blank space around the image, then the destination picbox will contain that extra space also when you StretchBlt.
If you need to just blt the area around the source image, excluding any extra space, you will have to calculate a tight rectangle around the image and just StretchBlt that rectangle's dimensions.
Regarding size ratios: If (sourceWidth/destWidth) <> (sourceHeight/destHeight) then you will not get a scaled rendering and you will have to determine what horizontal/vertical ratios to use.
sorry, but how can i resolve the problem?