Hi,
Could anyone tell me how to flip rectangles in picturebox?
Thanks
Printable View
Hi,
Could anyone tell me how to flip rectangles in picturebox?
Thanks
This might be of help to you :
http://www.codeguru.com/vb/gen/vb_gr...le.php/c14007/
Here's my code so far:
Dim g As Graphics = pb.CreateGraphics()
Dim x As Integer = CInt(CurrentRecord(4))
Dim y As Integer = CInt(CurrentRecord(6))
Dim width As Integer = CInt(CurrentRecord(5))
Dim height As Integer = CInt(CurrentRecord(7))
Dim rect As New Rectangle(x, y, width, height)
Dim redPen As New Pen(Color.Black, 2)
g.DrawRectangle(redPen, rect)
Dim mtx As New Matrix
redPen.Dispose()
g.Dispose()
I want to flip the rectangle upside down.
Thanks
You would have to know the SCALE of the view
Scaling is all fine. I only have to turn it upside down.
Thanks
Didn't you read the link I sent you Shers? In there I cover Rotation and Flipping
I went through the link and found that it's only for image rotation. My problem is rectangle flip vertical.
I'm attaching an image. If I change the y in
Dim rect As New Rectangle(x, y, width, height) to
Dim rect As New Rectangle(x, -y, width, height), I still see no change in the image. I drew a line to see how it works, and it still is below the line
Thanks
Firstly a recatangle no mater flipped which way will always look the same ... However if your trying to flip the image inside the rectangle the section titled Rotation on page two of Hanne's article is what your looking for... and you can use any of these options
It is nothing concerning image. I'm only drawing rectangles. A looping through results in a cluster of small and big rectangles which looks in an orderly manner. I want the final result to be flipped vertical as a whole, or flip each rectangle while looping through. That's what I tried, but looks like there's no change, as I drew a line to see where it is placed, but how much ever change I do, it still is below the line.
Thanks
Ahhh .... http://forums.codeguru.com/images/ie.../2011/08/1.gif
You not Flipping anything.... All you want to do is shift the position of the rectangle ..
Now you can change Ycenter to where you want the 'Illusion' of the flip to take place...Code:Dim Ycenter as integer = 0
Dim rect As New Rectangle(x, Ycenter- (y + height), width, height)
This why questions should be asked properly upfront, to avoid confusion ;)
If you check my signature, there's a link to the Crop & zoom thread.. It should give you all you the code you'll need to do the crop..
Just you may want too keep track of the Min & max of X and Y, and pass them through to the crop code, so that is an automatic and not manual crop..
Sorry, I checked the link and it's VB 6
Thanks
Wait .. Hannes did a line of articles...
I'll find the right one for you..
Ahh .. here we go
Creating Your Own Drawing Application with Visual Basic .NET, Part 4
And just in case there are links to the first three of the series in the article ...
Sorry again, that's not what I want. I drew an image in a picturebox with the image height as picturebox height and image width as picturebox width. The image is placed somewhere on the center of the picturebox. My intention is to scale the image to fit to the picturebox.
Thanks
If you are using the height and width then the result should be the same size unless of course you are not using the same scale. twips <> pixels for example
Silly suggestion. Look at the SizeMode property. There are options to AutoFit the image or to Stretch the image.
I really wish that one of my article can help you one day :cry: :)
Why don't I see anything in the picture box for this code?
x = 266
y = 14
width = 134
height = -14
g = Graphics.FromImage(bit)
g.DrawRectangle(myPen, x, 0 - (y + height), width, height)
g.DrawString("Test", New Font("Tahoma", 8), Brushes.Black, x, y)
myPen.Dispose()
g.Dispose()
Thanks
I do not see a reference to a picture box in the code