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?
sorry. but can you explain how we do filters?
you know, that i know working with pixels, but i don't understand how do filters
i wanted work\do nice filters when 1 image is resize it... because the stretchdibs() function don't give us good results
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.
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
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.
Code:
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!