Hi there,
When i am resizing a picture on the picture box control the picture is getting distorted or pixelated.n How do i resize the image without distortion.
thanks
Printable View
Hi there,
When i am resizing a picture on the picture box control the picture is getting distorted or pixelated.n How do i resize the image without distortion.
thanks
use this API call before resizing the picture:
VB Code:
Private Const HALFTONE = 4 Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) 'use SetStretchBltMode picHdc, HALFTONE
halftone is not supported in 95/98
Try this
Private Const COLORONCOLOR = 3
You can also try a bicubic/bilinear resize algorithm.
Sastraxi
Could you help me regarding the Bicubic/Bilinear resizing algorithm and how do i implement it in VB. Or may you could suggest some sites where i can get the information.
Fact is i need to include the image resizing in one of my modules. But the resultant image i got is being pixelated. I'm using the paintpicture method of the picture box.
I'm also in a lookout for resing the images using the code. I've tried also using the stretchblt API call but hte result seems to be the same.
Thanx in advance
I recommend getting the book Visual Basic Graphics programming. There are two functions you use, one for enlarging and one for shrinking, and you'll have to adapt it to your own code. Try searching google if you don't have this book for Resize Algorithm.
Sastraxi
:mad: :mad: :mad: :mad: :confused: :mad: :confused: :confused:
I've tried searching google for the resize algorithm, but there's no real code given in it. only lots and lots of text. I would like to go through any sample code which does the resizing and i can enhance it to fit my requirements.
Could u help me on this issue?
I have the code in my book but really don't have the time to write it out... sorry.
Strictly speaking, it is impossible to resize an image without distorting it, the trick is to distort it as little as possible, but its never going to be perfect.
Firstly, if you're resizing by a large amount, particularly if you're expanding an image it will look pixellated and crappy. Even a decent bicubic algorithm (say for example Photoshop's) won't be able to fix it if you're trying to make it really big.
Secondly, try to resize to a common factor or multiple of the images original size. shrinking an image to 50% will look better than shrinking it to 66.6% for example.
The whole subject is quite a complicated science. A google search could tell you more.
Learning the mechanics behind it will help you best manipulate it; don't jump straight in to code.
Fury2GE has Bi-Linear resampling, but the down-scaling is buggy. If you don't mind using a library, mine does it quite fast (in realtime, literally, for sizes below 640x480.)
http://fury2.happyapathy.com/fury2ge.exe
I've tried using StretchBlt for resizing the image in the picture box and the painting it into another picture box. but the destination picture box does not show any picture and the return value of StretchBlt is non-zero. I've aslo called the set stretchbltmode with the destination pic. box hdc as the first argument and COLORONCOLOR as the second. but still the problem is persisting kindly help on this.
:mad: :mad: :mad: :mad: :confused: :confused: :confused:
A non-zero return code means an error, you should look up the return code in the MSDN documentation for StretchBlt.
In MSDN it is listed as
If function succeds the return value is non-zero
if function fails the return value is zero
:confused: :confused: :confused: :D