i know catch the image to pixels... but i don't know work with image scaling
i know use the stretch api functions, but i wanted build nice alghoritmos... can anyone explain to me how can i create my own method?
i know catch the image to pixels... but i don't know work with image scaling
i know use the stretch api functions, but i wanted build nice alghoritmos... can anyone explain to me how can i create my own method?
on emulators we have very nice graphics filters for render an image. but i don't know how works. can anyone explain to me?
Look here Resize filter:
http://www.vbforums.com/showthread.p...raphic-filters
This is the usual linear interpolation pixel colors.
sorry, but i don't know how the linear interpolation pixel colors works
i know work with pixels, like you know. what i don't know is how the effects works. and more dificulty is the stretch(that it's my objective).
can you explain to me how can i resize an image(pseudo-code) by a pixel?
(by pixels, i know do: mirror and rotate an image and change colors and select an object and do a nice shadow... i don't know all)
Once again, Mikle generously offers the whole solution... Perhaps a simpler understanding of the process is what you desire? This pseudo code does NO INTERPOLATION of colors and is very slow.
xscale=(maxX+1)/maxx
yscale=(maxY+1)/maxy
for y=0 to maxY
for x=0 to maxX
col=pic1.point(x,y)
for y1=y*yscale to (y+1)*yscale
for x1=x*xscale to (x+1)*xscale
pic2.pset(x1,y1),col
next x1
next y1
next x
doevents
next y
Last edited by mikorians; Sep 24th, 2012 at 02:05 PM.
the maxX and maxY are the final size, right?
then what are xscale and yscale?
note the first two lines say maxX+1 and maxY+1
maxX and maxY are meant to be the 1st images size.
Also with this SIMPLE method - not using any color interpolation, you may notice a pair of vertical lines and a pair of horizontal lines that have the same color, and we did not 'dither' the colors throughout the 2nd image, so
what this does is probably leave you with vertical and horizontal stripe artifacts. I myself am not certain as to how to improve this by much without a much more complex mathematical algorithm with pic1.point(x+n,y+m) based color dithering with another pair of loops... or a more intelligent pset post-processing algorithm.
Last edited by mikorians; Sep 24th, 2012 at 02:21 PM.
But... Aside from these artifacts, you should be able to increase your image size by whatever you wish. This represents kinda what the built in stretchblit or paintpicture method does.
sorry... but i can't see a diference between the original image and the result
(picture1=original image... picture2=result)
for me seems the same... just a copy
Code:Option Explicit Private Sub Command1_Click() Dim x As Long Dim y As Long Dim col As Long Dim X1 As Long Dim y1 As Long Dim xscale As Long Dim yscale As Long xscale = (Picture1.Width + 1) / Picture1.Width yscale = (Picture1.Height + 1) / Picture1.Height For y = 0 To Picture1.Height For x = 0 To Picture1.Width col = Picture1.Point(x, y) For y1 = y * yscale To (y + 1) * yscale For X1 = x * xscale To (x + 1) * xscale Picture2.PSet (X1, y1), col Next X1 Next y1 Next x DoEvents Next y End Sub
xscale and yscale should be single not long - decimal values
You aren't going to notice much of any change with only 1 pixel of size difference
X1 Y1 should also be single I suppose. Aw fudge, I must be half-awake. I made 4 typos on this one post.
We're close now, stand by, testing app.. Mustof fudged my old math a bit...
The code did work with slight changes. Examine this.
Odd how the decimal math becomes your enemy at small size increases.
can you tell me theory of the code?
thanks for all
I verified exactly 1 pixel larger output on this app with a paint program.
This application performs a pair of classic Cartesian coordinate loops with simple division arithmetic to scale the values up or down by a tiny value that is proportional to the two different sizes of the images.
Version 2 is much faster. Hope you enjoy!
These are pretty sloppy and perform no error or numeric bounding tests, neither do they permit user data entry or save and load any images.
If you're in school for this, then study your algebra real hard now!
it can be more faster, but i see 2 errors:
1 - i see that left 1 pixel.. but i correct it;
2 - the image isn't resized.
thanks for allCode:Option Explicit Private Sub Command1_Click() 'Make certain the pictureboxes have scalemode set to pixels 'and autoredraw set to true Dim X As Long Dim Y As Long Dim Col As Long Dim X1 As Single Dim Y1 As Single Dim MaxX As Long Dim MaxY As Long Dim Xscale As Single Dim Yscale As Single MaxX = Picture1.ScaleWidth - 4 MaxY = Picture1.ScaleHeight - 4 Xscale = MaxX / (MaxX - 1) '55 pixels wider Yscale = MaxY / (MaxY - 1) '55 pixels higher For Y = 0 To MaxY + 1 For X = 0 To MaxX + 1 Col = Picture1.Point(X * Xscale, Y * Yscale) Picture2.PSet (X, Y), Col Next X DoEvents Next Y 'Picture2 is EXACTLY 1 pixel larger End Sub
My comments should have been '1 pixel wider and '1 pixel higher, respectively
As the file was verbatim worked. I don't know if the +1 is necessary in the two loops, but with the -1 on the scale, it should make it 2 pixels larger.
Whatever works for you, but don't exceed the size of your source picture's dimensions (picture1). I put a -4 because the 3d frame around the picturebox control messes us all up.
It's nitpicky with 1 pixel, but watch it if you go to larger size changes, you'll see what I mean.
I'm done now.
Good luck!
thanks for all my friend
You're welcome. We have a lot of time to burn around here. Happy to help!