private void setattributes() { float[][] colorMatrixElements = { new float[] {1, 0, 0, 0, 0}, // red scaling factor of 2 new float[] {0, 1, 0, 0, 0}, // green scaling factor of 1 new float[] {0, 0, 2, 0, 0}, // blue scaling factor of 1 new float[] {0, 0, 0, 1, 0}, // alpha scaling factor of 1 new float[] {-0.5f, -0.5f, .8f, 0, 1}}; // three translations of 0.2 cmuse = new ColorMatrix(colorMatrixElements); qcm = new QColorMatrix(cmuse); DrawAttributes = new ImageAttributes(); DrawAttributes.SetColorMatrix( qcm.ToColorMatrix(), ColorMatrixFlag.Default, ColorAdjustType.Bitmap); DrawAttributes.SetColorMatrix(cmuse); }
private void chooseimage() { //April 6th, birthday of windows 3.1 if (DateTime.Now.Month == 4 && DateTime.Now.Day == 6) { useBackground = panWin31.BackgroundImage; } else { //select a random start image from the available start images. GetSplashImages(); Image[] selectfrom = SplashImages; Image useimage = selectfrom[rgen.Next(selectfrom.Length)]; useBackground = useimage; } //new as of July 14th 2011: colourize to a random hue 50% of the time. if (rgen.NextDouble() > 0.5d) { //choose a random colour... Color colourizeto = new HSLColor(rgen.NextDouble() * 240, 240, 120); ImageAttributes attribcolourize = new ImageAttributes(); QColorMatrix qc = new QColorMatrix(); qc.RotateHue((float)(rgen.NextDouble()*255)); attribcolourize.SetColorMatrix(qc.ToColorMatrix()); // ColorMatrices.AddColourizer(attribcolourize, colourizeto); useBackground = BCBlockGameState.AppyImageAttributes(useBackground, attribcolourize); } Graphics drawtoit = Graphics.FromImage(useBackground); drawtoit.DrawImageUnscaled(RegUnregImage, 2, 2); drawtoit.Dispose(); }