internal static QIcon ConvertToQIcon(Image image) { QImage ms = ConvertToQImage(image); QPixmap px = QPixmap.FromImage(ms); return(new QIcon(px)); }
/// <summary> /// Convert Image to grayscale indexed image (like GIF) /// </summary> /// <param name="originalImage"></param> /// <returns></returns> public static QImage ConvertToGrayScaleIndexed(QImage originalImage) { var newImage = new QImage(originalImage.Size, QImage.Format.FormatGrayscale8); newImage.ColorCount = 256; for (int i = 0; i < 256; i++) { newImage.SetColor(i, qrgb.QRgb(i, i, i)); } // Add color table for image // [looking at example](http://stackoverflow.com/questions/5504768/how-to-use-a-color-lut-in-qt-qimage) for (int x = 0; x < originalImage.Width; x++) { for (int y = 0; y < originalImage.Height; y++) { var point = new QPoint(x, y); // pixel position UInt32 pixel = originalImage.Pixel(point); var gray = qrgb.QGray(pixel); newImage.SetPixel(point, qrgb.QRgb(gray, gray, gray)); } } //newImage.Save ( @"d:\dump.png", "png" ); return(newImage); }
public static QImage ConvolveInteger(QImage img, int matrix_size, ref int matrix) { StackItem[] stack = new StackItem[4]; #if DEBUG stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(img); #else stack[1].s_class = (IntPtr)GCHandle.Alloc(img); #endif stack[2].s_int = matrix_size; stack[3].s_int = matrix; staticInterceptor.Invoke("convolveInteger#$$", "convolveInteger(QImage&, int, int*)", stack); #if DEBUG DebugGCHandle.Free((GCHandle)stack[1].s_class); #else ((GCHandle)stack[1].s_class).SynchronizedFree(); #endif matrix = stack[3].s_int; object returnValue = ((GCHandle)stack[0].s_class).Target; #if DEBUG DebugGCHandle.Free((GCHandle)stack[0].s_class); #else ((GCHandle)stack[0].s_class).SynchronizedFree(); #endif return((QImage)returnValue); }
public void OnStart(QGetContent content) { p = GetComponent <Player>("Player"); Image = new QImage(this, "BryanStuff1"); Image.Origin = new QVec(16); Transform.Scale = new QVec(4); }
public void OnStart(QGetContent get) { Heart = get.TextureSource("BryanStuff1").Split(32, 32)[21]; EmptyHeart = get.TextureSource("BryanStuff1").Split(32, 32)[22]; p = GetBehavior <Player>(); GuiHeart = new QImage(this, Heart); GuiEmptyHeart = new QImage(this, EmptyHeart); GuiHeart.Scale = new QVec(4); GuiEmptyHeart.Scale = new QVec(4); }
internal static QImage ConvertToQImage(Image image) { QImage result; using (MemoryStream ms = new MemoryStream()) { image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); result = QImage.FromData(new QByteArray(ms.GetBuffer()), "PNG"); } return(result); }
public static void LoadExamQuestions(Exam exam) { string dirpath = Directory.GetCurrentDirectory(); string filePath = dirpath + "\\" + exam.QuestionsPath; try { var xml = XDocument.Load(filePath); XElement elementXml = XElement.Parse(xml.ToString()); // exam.Title = elementXml.Name.ToString().Replace("_", " "); var questionsElement = elementXml.Elements(); foreach (var xQuestion in questionsElement.Elements()) { IQuestion question; if (xQuestion.Name == "MultipleChoiseTextQuestion") { question = new MultipleChoiceTextQuestion(); var answers = xQuestion.Element("Answers"); foreach (var answer in answers.Elements()) { (question as MultipleChoiceTextQuestion).Answers.Add(answer.Value); } } else { question = new OpenQuestion(); } question.Points = double.Parse(xQuestion.Element("Points").Value); question.RightAnswer = xQuestion.Element("RightAnswer").Value; question.QuestionDescription = xQuestion.Element("QuestionDescription").Value; question.QuestionText = xQuestion.Element("QuestionText").Value; if (xQuestion.Element("Image_Id") != null) { using (var unit = new UnitOfWork(new ExamContext())) { int imageId = int.Parse(xQuestion.Element("Image_Id").Value); QImage qImgModel = unit.QImages .Find(img => (img.ExamId == exam.Id) && (img.Id == imageId)) .ToList()[0]; question.QuestionImage = ByteArrayToImage(qImgModel.QuestionImage); } } exam.Questions.Add(question); } } catch { } }
/// <summary> /// Convert RGBA image to grayscale RGBA /// </summary> /// <param name="originalImage"></param> /// <returns></returns> public static QImage ConvertToGrayScale(QImage originalImage) { var newImage = originalImage.Copy(); for (int x = 0; x < originalImage.Width; x++) { for (int y = 0; y < originalImage.Height; y++) { var point = new QPoint(x, y); // pixel position using (var color = originalImage.PixelColor(point)) { UInt32 pixel = originalImage.Pixel(point); int alpha = color.Alpha; int gray = qrgb.QGray(pixel); using (var qColor = new QColor(gray, gray, gray, alpha)) { newImage.SetPixelColor(point, qColor); } } } } return(newImage); }
/// <remarks> /// Produces a "charcoal" image effect. /// <param> name="img" The image to process. /// </param></remarks> <return> The processed image. The original is not changed. /// </return> /// <author> Daniel M. Duley (mosfet) /// </author> /// <short> Produces a "charcoal" image effect.</short> public static QImage Charcoal(QImage img) { return((QImage)staticInterceptor.Invoke("charcoal#", "charcoal(QImage&)", typeof(QImage), typeof(QImage), img)); }
public static QImage OilPaint(QImage img) { return((QImage)staticInterceptor.Invoke("oilPaint#", "oilPaint(QImage&)", typeof(QImage), typeof(QImage), img)); }
public static QImage OilPaint(QImage img, float radius) { return((QImage)staticInterceptor.Invoke("oilPaint#$", "oilPaint(QImage&, float)", typeof(QImage), typeof(QImage), img, typeof(float), radius)); }
public static QImage Threshold(QImage img, ushort thresholdValue, Blitz.RGBChannel channel) { return((QImage)staticInterceptor.Invoke("threshold#$$", "threshold(QImage&, unsigned char, Blitz::RGBChannel)", typeof(QImage), typeof(QImage), img, typeof(ushort), thresholdValue, typeof(Blitz.RGBChannel), channel)); }
/// <remarks> /// Desaturate an image evenly. /// <param> name="img" The image to process. /// </param><param> name="desat" A value between 0 and 1 setting the degree of desaturation /// </param></remarks> <return> A reference to the image for convenience. /// </return> /// <author> Daniel M. Duley (mosfet) /// </author> /// <short> Desaturate an image evenly.</short> public static QImage Desaturate(QImage img, float desat) { return((QImage)staticInterceptor.Invoke("desaturate#$", "desaturate(QImage&, float)", typeof(QImage), typeof(QImage), img, typeof(float), desat)); }
public Paint_GrayscaleImage( ) { colorImage = media.MediaGfxHelper.PancakeImage.ScaledToWidth(400, mode: TransformationMode.SmoothTransformation); // get image //grayscaleImage = ConvertToGrayScale ( colorImage ); grayscaleImage = ConvertToGrayScaleIndexed(colorImage); }
public static QImage Desaturate(QImage img) { return((QImage)staticInterceptor.Invoke("desaturate#", "desaturate(QImage&)", typeof(QImage), typeof(QImage), img)); }
public static QImage Implode(QImage img) { return((QImage)staticInterceptor.Invoke("implode#", "implode(QImage&)", typeof(QImage), typeof(QImage), img)); }
/// <remarks> /// Implodes an image by a specified percent. /// <param> name="img" The QImage to process. /// </param><param> name="amount" The extent of the implosion. /// </param></remarks> <return> The processed image. The original is not changed. /// </return> /// <author> Daniel M. Duley (mosfet) /// </author> /// <short> Implodes an image by a specified percent.</short> public static QImage Implode(QImage img, float amount) { return((QImage)staticInterceptor.Invoke("implode#$", "implode(QImage&, float)", typeof(QImage), typeof(QImage), img, typeof(float), amount)); }
public static QImage Swirl(QImage img) { return((QImage)staticInterceptor.Invoke("swirl#", "swirl(QImage&)", typeof(QImage), typeof(QImage), img)); }
/// <remarks> /// Swirls the image by a specified amount /// <param> name="img" The image to process. /// </param><param> name="degrees" The tightness of the swirl. /// </param></remarks> <return> The processed image. The original is not changed. /// </return> /// <author> Daniel M. Duley (mosfet) /// </author> /// <short> Swirls the image by a specified amount </short> public static QImage Swirl(QImage img, float degrees) { return((QImage)staticInterceptor.Invoke("swirl#$", "swirl(QImage&, float)", typeof(QImage), typeof(QImage), img, typeof(float), degrees)); }
public static QImage Threshold(QImage img) { return((QImage)staticInterceptor.Invoke("threshold#", "threshold(QImage&)", typeof(QImage), typeof(QImage), img)); }
public static QImage Threshold(QImage img, ushort thresholdValue) { return((QImage)staticInterceptor.Invoke("threshold#$", "threshold(QImage&, unsigned char)", typeof(QImage), typeof(QImage), img, typeof(ushort), thresholdValue)); }
/// <remarks> /// Modulate the image with a color channel of another image. /// <param> name="img" The QImage to modulate and result. /// </param><param> name="modImg" The QImage to use for modulation. /// </param><param> name="reverse" Invert the meaning of image/modImage; result is image! /// </param><param> name="type" The modulation Type to use. /// </param><param> name="factor" The modulation amplitude; with 0 no effect [-200;200]. /// </param><param> name="channel" The RBG channel of image2 to use for modulation. /// </param></remarks> <return> Returns the image(), provided for convenience. /// </return> /// <short> Modulate the image with a color channel of another image.</short> public static QImage Modulate(QImage img, QImage modImg, bool reverse, Blitz.ModulationType type, int factor, Blitz.RGBChannel channel) { return((QImage)staticInterceptor.Invoke("modulate##$$$$", "modulate(QImage&, QImage&, bool, Blitz::ModulationType, int, Blitz::RGBChannel)", typeof(QImage), typeof(QImage), img, typeof(QImage), modImg, typeof(bool), reverse, typeof(Blitz.ModulationType), type, typeof(int), factor, typeof(Blitz.RGBChannel), channel)); }
/// <remarks> /// Fade an image to a certain background color. The number of colors will /// not be changed. /// <param> name="img" The image to process. /// </param><param> name="val" The strength of the effect. 0 <= val <= 1. /// </param><param> name="color" The background color. /// </param></remarks> <return> A reference to the image for convenience. /// </return> /// <short> Fade an image to a certain background color.</short> public static QImage Fade(QImage img, float val, QColor color) { return((QImage)staticInterceptor.Invoke("fade#$#", "fade(QImage&, float, const QColor&)", typeof(QImage), typeof(QImage), img, typeof(float), val, typeof(QColor), color)); }
/// <remarks> /// This recolors a pixmap. The most dark color will become color a, /// the most bright one color b, and in between. /// <param> name="img" The image to process. /// </param><param> name="ca" Color a /// </param><param> name="cb" Color b /// </param></remarks> <short> This recolors a pixmap.</short> public static QImage Flatten(QImage img, QColor ca, QColor cb) { return((QImage)staticInterceptor.Invoke("flatten###", "flatten(QImage&, const QColor&, const QColor&)", typeof(QImage), typeof(QImage), img, typeof(QColor), ca, typeof(QColor), cb)); }
private void DoneImage(QImage img) { img.Dispose(); this.MoveFile(img.FileInfo, DONE_FOLDER); }
public static QImage Wave(QImage img, float amplitude) { return((QImage)staticInterceptor.Invoke("wave#$", "wave(QImage&, float)", typeof(QImage), typeof(QImage), img, typeof(float), amplitude)); }
public static QImage Wave(QImage img) { return((QImage)staticInterceptor.Invoke("wave#", "wave(QImage&)", typeof(QImage), typeof(QImage), img)); }
/// <remarks> /// Produces an oil painting effect. /// <param> name="img" The image to process. /// </param><param> name="radius" The radius of the gaussian, not counting the center /// pixel. Use 0, (recommended), and an appropriate one will be used. /// </param><param> name="quality" Determines if to use a small or large convolution matrix. /// </param></remarks> <return> The processed image. The original is not changed. /// </return> /// <author> Daniel M. Duley (mosfet) /// </author> /// <short> Produces an oil painting effect.</short> public static QImage OilPaint(QImage img, float radius, Blitz.EffectQuality quality) { return((QImage)staticInterceptor.Invoke("oilPaint#$$", "oilPaint(QImage&, float, Blitz::EffectQuality)", typeof(QImage), typeof(QImage), img, typeof(float), radius, typeof(Blitz.EffectQuality), quality)); }
/// <remarks> /// Modifies the pixels along a sine wave. /// <param> name="img" The image to process. /// </param><param> name="amplitude" The amplitude of the sine wave. /// </param><param> name="frequency" The frequency of the sine wave. /// </param><param> name="background" An RGBA value to use for the background. After the /// effect some pixels may be "empty". This value is used for those pixels. /// </param></remarks> <return> The processed image. The original is not changed. /// </return> /// <author> Daniel M. Duley (mosfet) /// </author> /// <short> Modifies the pixels along a sine wave.</short> public static QImage Wave(QImage img, float amplitude, float frequency, uint background) { return((QImage)staticInterceptor.Invoke("wave#$$$", "wave(QImage&, float, float, unsigned int)", typeof(QImage), typeof(QImage), img, typeof(float), amplitude, typeof(float), frequency, typeof(uint), background)); }
/// <remarks> /// Thresholds an image based on a given channel and threshold value. /// <param> name="img" The image to process. /// </param><param> name="thresholdValue" The value that separates "on" colors from "off" /// ones. /// </param><param> name="channel" The channel to use when thresholding. /// </param><param> name="aboveColor" The color to use for values at or above the threshold. /// </param><param> name="belowColor" The color to use for values below the threshold. /// </param></remarks> <return> The processed image. The original is not changed. /// </return> /// <author> Daniel M. Duley (mosfet) /// </author> /// <short> Thresholds an image based on a given channel and threshold value.</short> public static QImage Threshold(QImage img, ushort thresholdValue, Blitz.RGBChannel channel, uint aboveColor, uint belowColor) { return((QImage)staticInterceptor.Invoke("threshold#$$$$", "threshold(QImage&, unsigned char, Blitz::RGBChannel, unsigned int, unsigned int)", typeof(QImage), typeof(QImage), img, typeof(ushort), thresholdValue, typeof(Blitz.RGBChannel), channel, typeof(uint), aboveColor, typeof(uint), belowColor)); }