Mã:
public static void ApplyTexture (Image img, Image texture, float textureTransparency){ if ( (img ==null) || (texture==null) ) throw new ArgumentNullException(); if (textureTransparency < 0 || textureTransparency > 1) throw new ArgumentOutOfRangeException( "Gia tri tu 0 den 1."); // Chuyen anh qua mau gray truoc MakeImageGrayscale (texture); Bitmap txtr = new Bitmap(texture); BitmapData bmData = txtr.LockBits(new Rectangle(0, 0, txtr.Width, txtr.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); int stride = bmData.Stride; System.IntPtr Scan0 = bmData.Scan0; unsafe { byte * p = (byte *)(void *)Scan0; int nOffset = stride - txtr.Width*4; for (int y=0; y < txtr.Height; ++y) { for (int x=0; x < txtr.Width; ++x) { p[3] = (byte)(p[0] * textureTransparency); p += 4; // Move to the next pixel } p += nOffset; } } txtr.UnlockBits(bmData); Graphics gr = Graphics.FromImage(img); TextureBrush myBrush = new TextureBrush(txtr); gr.FillRectangle (myBrush,0,0,img.Width, img.Height); myBrush.Dispose(); gr.Dispose(); txtr.Dispose();} // Chuyen mot anh thanh mau xampublic static void MakeImageGrayscale (Image img){ ColorMatrix cMatrix = new ColorMatrix ( new float[][] { new float[] {0.299F, 0.299F, 0.299F, 0, 0}, new float[] {0.587F, 0.587F, 0.587F, 0, 0}, new float[] {0.114F, 0.114F, 0.114F, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 1, 0}}); ImageAttributes imageAttrib = new ImageAttributes(); imageAttrib.SetColorMatrix(cMatrix); Graphics gr = Graphics.FromImage (img); gr.DrawImage (img, new Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttrib); gr.Dispose();} // st codeproject.com
Tuy nhiên, việc thi công và bảo dưỡng đường bê tông nhựa đòi hỏi sự chuyên nghiệp và kỹ thuật cao từ các nhà thầu và kỹ sư. Sự linh hoạt và độ bền cao của đường bê tông nhựa cũng giúp giảm thiểu chi...
Xây Dựng Đẳng Cấp: Cùng Đại Thanh,...