vb.net - Image zoom WITH pixelation -


I am zooming an image in the image box using this code on the track box.

  private sub TbrZoomLevel_Scroll (as in this System.Object, e System.EventArgs) Handles (with tbrZoomLevel.Scroll pbImage .SuspendLayout) .Width = actualSize.Width * tbrZoomLevel. Value .ightight = actualSize.Height * tbrZoomLevel.Value .ResumeLayout () end is ending with a pictureBox control with sizmode in the form of pbImage zoom sub  

The actual size is the original size of the image in PbImage.

When I zoom in, I get the image without pixelation. But I want to pixel it completely and show the picture shown in MS paint on zooming. Any help is appreciated VB.Net code, C # code or just any algorithm is welcomed.

In your picture box color:

  private subPicBox1_Paint (this as System.Object, e System.Windows.Forms.PaintEventArgs) handles PictureBox1.Paint e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor 'image End Sub Draw  

eDIT: Try this

  private sub PictureBox1_Paint (such as System.Object, e System.Windows.Forms.PaintEventArgs as) handles PictureBox1.Paint dim srcRect RectangleF = new Rectangle (0, 0, PictureBox1.Width / 8, PictureBox1.Height / 8) dim dstRect RectangleF = new RectangleF (0, 0, PictureBox1.Width, PictureBox1.Height) e.Graphics.InterpolationMode = Drawing2D a As in the form of. InterpolationMode.NearestNeighbor e.Graphics.DrawImage (pctBoxImage, dstRect, srcRect, GraphicsUnit.Pixel) End Sub  

pctBoxImage bitmap which It may be that 800% zoomed

or

  private sub-picturebox 1_Paint (sender, as the system object, and system as. Windows.Forms.PaintEventArgs) handles PictureBox1.Paint e.Graphics.ScaleTransform (8, 8) e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor e.Graphics.DrawImage (pctBoxImage, 0, 0) End Sub < / Code> 

0,0 byte-up corner position is at bitmap coordinates

v Alter


Comments