public ContentEditor_Image(DataStore dataStore, SelectButton control) { InitializeComponent(); data = dataStore; cont = control; R_ImageFill.Fill = new ImageBrush(((Image)cont.Content).Source); ((ImageBrush)R_ImageFill.Fill).Stretch = Stretch.UniformToFill; TB_Width.Text = "" + cont.Width; TB_Height.Text = "" + cont.Height; TB_MarginLeft.Text = "" + cont.Margin.Left; ComboBox_Stretch.SelectedIndex = (int)((Image)cont.Content).Stretch; BitmapScalingMode bitmapScalingMode = ((Content_Image)cont.Tag).scalingMode; if (bitmapScalingMode == BitmapScalingMode.Fant) { ComboBox_Quality.SelectedIndex = 0; } else if (((Content_Image)cont.Tag).scalingMode == BitmapScalingMode.NearestNeighbor) { ComboBox_Quality.SelectedIndex = 2; } else { ComboBox_Quality.SelectedIndex = 1; } }
/// <summary> /// Creates a scaled copy of a BitmapSource. Only scales up, using nearest-neighbor. /// </summary> public static BitmapSource CreateScaledCopy(this BitmapSource src, int scale) { // Simple approach always does a "blurry" scale. //return new TransformedBitmap(src, new ScaleTransform(scale, scale)); // Adapted from https://weblogs.asp.net/bleroy/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi // (found via https://stackoverflow.com/a/25570225/294248) BitmapScalingMode scalingMode = BitmapScalingMode.NearestNeighbor; int newWidth = (int)src.Width * scale; int newHeight = (int)src.Height * scale; var group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(src, new Rect(0, 0, newWidth, newHeight))); var targetVisual = new DrawingVisual(); var targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); var target = new RenderTargetBitmap( newWidth, newHeight, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); var targetFrame = BitmapFrame.Create(target); return(targetFrame); }
public SwitchItem(Brush background, object value, string content, BitmapScalingMode scalingMode = BitmapScalingMode.HighQuality) { Background = background; Value = value; ScalingMode = scalingMode; Content = content; }
public void Stub01() { // <SnippetRenderOptionsSnippet1> // Get the bitmap scaling mode for the image. BitmapScalingMode bitmapScalingMode = RenderOptions.GetBitmapScalingMode(MyImage); // </SnippetRenderOptionsSnippet1> }
public static void SetBitmapScalingMode(DependencyObject obj, BitmapScalingMode bitmapScalingMode) { NoesisGUI_PINVOKE.RenderOptions_SetBitmapScalingMode(DependencyObject.getCPtr(obj), (int)bitmapScalingMode); if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) { throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); } }
/// <summary> /// Writes the attached property BitmapScalingMode to the given object. /// </summary> public static void SetBitmapScalingMode(DependencyObject target, BitmapScalingMode bitmapScalingMode) { if (target == null) { throw new ArgumentNullException("target"); } target.SetValue(BitmapScalingModeProperty, bitmapScalingMode); }
public ImageExtension(ImageSource source, int width, int height, BitmapScalingMode scalingMode) { if (width < 0) throw new ArgumentOutOfRangeException(nameof(width)); if (height < 0) throw new ArgumentOutOfRangeException(nameof(height)); this.source = source; this.width = width; this.height = height; this.scalingMode = scalingMode; }
public ImageExtension(ImageSource source, int width, int height, BitmapScalingMode scalingMode) { if (width < 0) throw new ArgumentOutOfRangeException(nameof(width)); if (height < 0) throw new ArgumentOutOfRangeException(nameof(height)); this.source = source; this.width = width; this.height = height; this.scalingMode = scalingMode; }
/// <summary>Captures a snapshot of the source element as a bitmap image. The snapshot is created based on the specified rendering parameters.</summary> /// <param name="sourceElement">The source element.</param> /// <param name="bitmapSize">The bitmap size.</param> /// <param name="scalingMode">The bitmap scaling mode.</param> /// <param name="bitmapDpi">The bitmap dpi.</param> /// <param name="pixelFormat">The bitmap pixel format.</param> /// <returns>The snapshot of the source element.</returns> public static BitmapSource CaptureSnapshot(FrameworkElement sourceElement, Size bitmapSize, BitmapScalingMode scalingMode, Vector bitmapDpi, PixelFormat pixelFormat) { if (sourceElement == null || bitmapSize.IsZero()) return null; var snapshot = new RenderTargetBitmap((int)bitmapSize.Width, (int)bitmapSize.Height, bitmapDpi.X, bitmapDpi.Y, pixelFormat); sourceElement.SetValue(RenderOptions.BitmapScalingModeProperty, scalingMode); snapshot.Render(sourceElement); sourceElement.ClearValue(RenderOptions.BitmapScalingModeProperty); snapshot.Freeze(); return snapshot; }
/// <summary> /// ビットマップ画像を生成します。 /// </summary> public static BitmapImage CreateBitmapImage(string filePath, bool freezing, BitmapScalingMode scalingMode) { var bitmapImage = CreateBitmapImage(filePath, freezing); // 品質指定つき RenderOptions.SetBitmapScalingMode(bitmapImage, scalingMode); return(bitmapImage); }
public static Windows.Controls.Image ToImage(this BitmapImage bitmap, BitmapScalingMode scaling = BitmapScalingMode.Fant) { var image = new Windows.Controls.Image() { Source = bitmap }; RenderOptions.SetBitmapScalingMode(image, scaling); return(image); }
public static BitmapScalingMode GetBitmapScalingMode(DependencyObject obj) { BitmapScalingMode ret = (BitmapScalingMode)NoesisGUI_PINVOKE.RenderOptions_GetBitmapScalingMode(DependencyObject.getCPtr(obj)); if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) { throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
private static BitmapFrame Rotate(BitmapFrame photo, double angle, BitmapScalingMode mode) { TransformedBitmap target = new TransformedBitmap( photo, new RotateTransform(angle, photo.PixelWidth / 2, photo.PixelHeight / 2)); BitmapFrame thumbnail = BitmapFrame.Create(target); BitmapFrame newPhoto = Resize(thumbnail, photo.PixelWidth, photo.PixelHeight, mode); return(newPhoto); }
public static void SetBitmapScalingMode(DependencyObject obj, BitmapScalingMode bitmapScalingMode) { if (obj == null) { throw new ArgumentNullException("obj"); } { NoesisGUI_PINVOKE.RenderOptions_SetBitmapScalingMode(DependencyObject.getCPtr(obj), (int)bitmapScalingMode); } }
public void Stub02() { BitmapScalingMode bitmapScalingMode = RenderOptions.GetBitmapScalingMode(MyImage); // <SnippetRenderOptionsSnippet2> // Set the bitmap scaling mode for the image to render faster. RenderOptions.SetBitmapScalingMode(MyImage, BitmapScalingMode.LowQuality); // </SnippetRenderOptionsSnippet2> bitmapScalingMode = RenderOptions.GetBitmapScalingMode(MyImage); }
/// <summary> /// Returns whether or not an enumeration instance a valid value. /// This method is designed to be used with ValidateValueCallback, and thus /// matches it's prototype. /// </summary> /// <param name="valueObject"> /// Enumeration value to validate. /// </param> /// <returns> 'true' if the enumeration contains a valid value, 'false' otherwise. </returns> public static bool IsBitmapScalingModeValid(object valueObject) { BitmapScalingMode value = (BitmapScalingMode)valueObject; return((value == BitmapScalingMode.Unspecified) || (value == BitmapScalingMode.LowQuality) || (value == BitmapScalingMode.HighQuality) || (value == BitmapScalingMode.Linear) || (value == BitmapScalingMode.Fant) || (value == BitmapScalingMode.NearestNeighbor)); }
public static BitmapScalingMode GetBitmapScalingMode(DependencyObject obj) { if (obj == null) { throw new ArgumentNullException("obj"); } { BitmapScalingMode ret = (BitmapScalingMode)NoesisGUI_PINVOKE.RenderOptions_GetBitmapScalingMode(DependencyObject.getCPtr(obj)); return(ret); } }
public static BitmapFrame Resize(this BitmapFrame frame, int percentage, BitmapScalingMode mode = BitmapScalingMode.NearestNeighbor) { if (frame.IsNullOrEmpty() || percentage <= 0) { return(null); } int width = (int)((decimal)frame.Width).FindValueByPercentages(100, percentage); int height = (int)((decimal)frame.Height).FindValueByPercentages(100, percentage); return(frame.Resize(width, height, mode)); }
public static void SetBitmapScalingMode(DependencyObject target, BitmapScalingMode bitmapScalingMode) { // http://blogs.msdn.com/wpf3d/archive/2009/06/24/what-s-new-in-graphics-for-4-0-beta-1.aspx // The default RenderOptions.BitmapScalingMode (Unspecified) is now Linear instead of Fant. If you still want Fant, you can re-enable it. var i = target as Image; if (i != null) { var i_ = (__Image)(object)i; } }
public static Image GetImageFromFile(string path, BitmapScalingMode scaling = BitmapScalingMode.HighQuality, double height = 16, double width = 16) { var image = new Image() { Source = System.Drawing.Imaging.BitmapExtensions.BitmapFromFile(path), Height = height, Width = width }; RenderOptions.SetBitmapScalingMode(image, scaling); return(image); }
public static Image GetImageFromResource(string path, string assemblyName, BitmapScalingMode scaling = BitmapScalingMode.HighQuality, double height = 16, double width = 16) { var image = new Image() { Source = new BitmapImage(new Uri($"pack://application:,,,/{assemblyName};component/" + path, UriKind.Absolute)), Height = height, Width = width }; RenderOptions.SetBitmapScalingMode(image, scaling); return(image); }
public static BitmapFrame Resize(this BitmapSource bitmap, int width, int height, BitmapScalingMode scalingMode = BitmapScalingMode.HighQuality) { var group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(bitmap, new Rect(0, 0, width, height))); var targetVisual = new DrawingVisual(); var targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); var target = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); var targetFrame = BitmapFrame.Create(target); return targetFrame; }
public static Stream Resize(string photoPath, int maxWidth, BitmapScalingMode scalingMode) { lock (lockObject) { var s = DateTime.Now; var fileInfo = new FileInfo(photoPath); var photoDecoder = BitmapDecoder.Create(new Uri(photoPath), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None); var photo = photoDecoder.Frames[0]; var metaInfo = photo.Metadata; double width = photo.PixelWidth; double height = photo.PixelHeight; if (photo.PixelWidth > maxWidth) { var a = (double)maxWidth / photo.PixelWidth; width = maxWidth; height *= a; } var group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode( group, scalingMode); group.Children.Add( new ImageDrawing(photo, new System.Windows.Rect(0, 0, (int)width, (int)height))); var targetVisual = new DrawingVisual(); var targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); var target = new RenderTargetBitmap( (int)width, (int)height, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); var targetFrame = BitmapFrame.Create(target, photo.Thumbnail, (BitmapMetadata)metaInfo.Clone(), photo.ColorContexts); var memoryStream = new MemoryStream(); var targetEncoder = new JpegBitmapEncoder(); targetEncoder.Frames.Add(targetFrame); targetEncoder.Save(memoryStream); Console.WriteLine("path: {0} org: {1}*{2} target: {3}*{4} cost:{5}ms size:{6}KB->{7}KB", photoPath, photo.PixelWidth, photo.PixelHeight, width, height, (DateTime.Now - s).TotalMilliseconds.ToString("0.00"), (int)fileInfo.Length / 1024, (int)memoryStream.Length / 1024); return memoryStream; } }
private static BitmapFrame Resize(BitmapFrame photo, int width, int height, BitmapScalingMode scalingMode) { DrawingGroup group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(photo, new Rect(0, 0, width, height))); DrawingVisual targetVisual = new DrawingVisual(); DrawingContext targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); RenderTargetBitmap target = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); BitmapFrame targetFrame = BitmapFrame.Create(target); return targetFrame; }
public static BitmapFrame Resize(this BitmapSource photo, BitmapScalingMode scalingMode, bool preserveAspect, int width, int height) { DrawingGroup group = new DrawingGroup(); double sourceHeight = photo.Height; double sourceWidth = photo.Width; double aspectRatio = sourceHeight/sourceWidth; double newWidth = 0; double newHeight = 0; if (preserveAspect) { if (width > 0) { newWidth = width; newHeight = Math.Round(width * aspectRatio, 0, MidpointRounding.AwayFromZero); } else if (height > 0) { newWidth = Math.Round(height / aspectRatio, 0, MidpointRounding.AwayFromZero); newHeight = height; } } else { newWidth = width; newHeight = height; } float dpiX; float dpiY; using (var graphics = Graphics.FromHwnd(IntPtr.Zero)) { dpiX = graphics.DpiX; dpiY = graphics.DpiY; } RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(photo, new Rect(0, 0, newWidth, newHeight))); DrawingVisual targetVisual = new DrawingVisual(); DrawingContext targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); RenderTargetBitmap target = new RenderTargetBitmap((int)newWidth, (int)newHeight, dpiX, dpiY, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); return BitmapFrame.Create(target); }
public static void SetBitmapScalingMode(DependencyObject target, BitmapScalingMode bitmapScalingMode) { // http://blogs.msdn.com/wpf3d/archive/2009/06/24/what-s-new-in-graphics-for-4-0-beta-1.aspx // The default RenderOptions.BitmapScalingMode (Unspecified) is now Linear instead of Fant. If you still want Fant, you can re-enable it. var i = target as Image; if (i != null) { var i_ = (__Image)(object)i; } }
public Value_ScalableImage(DataStore datas, ScalableImage image) { InitializeComponent(); cont = image; data = datas; positionselector.SetData(cont); positionselector.LoadData(); effectselector.SetData(cont); effectselector.LoadData(); BitmapScalingMode scalingMode = RenderOptions.GetBitmapScalingMode(cont); if ((int)scalingMode == 2) { ComboBox_Quality.SelectedIndex = 0; } if ((int)scalingMode == 1) { ComboBox_Quality.SelectedIndex = 1; } if ((int)scalingMode == 3) { ComboBox_Quality.SelectedIndex = 2; } if (cont.M_Img.Source != null) { R_ImageFill.Fill = new ImageBrush(cont.M_Img.Source); ((ImageBrush)R_ImageFill.Fill).Stretch = Stretch.UniformToFill; } SliderZoom.Value = cont.SliderZoom.Value; NTB_Zoom.Text = "" + (int)SliderZoom.Value; GetImageSize(); BS_ControlPanel.SetData(cont, data, false, cont.PathToCPImage); BS_ControlPanel.LoadData(cont.ControlPanelBack); BS_ControlPanel.ChangedBrush -= ControlBackground_ChangedBrush; BS_ControlPanel.ChangedBrush += ControlBackground_ChangedBrush; }
private static BitmapFrame GetBitmapFrame(MemoryStream original, int width, int height, BitmapScalingMode mode) { BitmapDecoder photoDecoder = BitmapDecoder.Create(original, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None); BitmapFrame photo = photoDecoder.Frames[0]; TransformedBitmap target = new TransformedBitmap( photo, new ScaleTransform( width / photo.Width * 96 / photo.DpiX, height / photo.Height * 96 / photo.DpiY, 0, 0)); BitmapFrame thumbnail = BitmapFrame.Create(target); BitmapFrame newPhoto = Resize(thumbnail, width, height, mode); return newPhoto; }
private static BitmapFrame Resize(BitmapFrame photo, int width, int height, BitmapScalingMode scalingMode) { DrawingGroup group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(photo, new Rect(0, 0, width, height))); DrawingVisual targetVisual = new DrawingVisual(); DrawingContext targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); RenderTargetBitmap target = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); BitmapFrame targetFrame = BitmapFrame.Create(target); return(targetFrame); }
private static BitmapFrame Resize(BitmapFrame photo, int width, int height, BitmapScalingMode scalingMode = BitmapScalingMode.Fant) { // This is a more flexible, albiet slower alternative to FastResize. For more info: // http://weblogs.asp.net/bleroy/archive/2009/12/10/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi.aspx var group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(photo, new Rect(0, 0, width, height))); var targetVisual = new DrawingVisual(); DrawingContext targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); var target = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); return(BitmapFrame.Create(target)); }
public Value_Image(DataStore datas, Image image) { InitializeComponent(); cont = image; data = datas; positionselector.SetData(cont); positionselector.LoadData(); effectselector.SetData(cont); effectselector.LoadData(); ComboBox_Stretch.SelectedIndex = (int)image.Stretch; BitmapScalingMode scalingMode = RenderOptions.GetBitmapScalingMode(cont); if ((int)scalingMode == 2) { ComboBox_Quality.SelectedIndex = 0; } if ((int)scalingMode == 1) { ComboBox_Quality.SelectedIndex = 1; } if ((int)scalingMode == 3) { ComboBox_Quality.SelectedIndex = 2; } if (cont.Source != null) { R_ImageFill.Fill = new ImageBrush(cont.Source); ((ImageBrush)R_ImageFill.Fill).Stretch = Stretch.UniformToFill; ComboBox_Stretch.SelectedIndex = (int)cont.Stretch; } GetImageSize(); }
public static BitmapFrame Resize(Stream photoStream, int width, int height, BitmapScalingMode scalingMode) { var photoDecoder = BitmapDecoder.Create(photoStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None); var photo = photoDecoder.Frames[0]; var group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(photo, new Rect(0, 0, width, height))); var targetVisual = new DrawingVisual(); var targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); var target = new RenderTargetBitmap( width, height, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); var targetFrame = BitmapFrame.Create(target); return(targetFrame); }
public void Serialize(Control element,Brush brush, DataStore data ) { if (brush != null) { if(brush is ImageBrush) { if (element.Tag != null) { DesignSave ds = DesignSave.Deserialize(element.Tag.ToString()); ds.Background.stretch = ((ImageBrush)brush).Stretch; designSave = ds; isImage = true; ScaleQuality = RenderOptions.GetBitmapScalingMode(element); ds.SerializeTransform(brush, ds.Background); } } else { BrushS = SaveEditor.XMLSerialize(brush); isImage = false; } } }
public static BitmapFrame GetBitmapFrame(BitmapFrame photo, int width, int height, BitmapScalingMode mode) { TransformedBitmap target = new TransformedBitmap( photo, new ScaleTransform( width / photo.Width * 96 / photo.DpiX, height / photo.Height * 96 / photo.DpiY, 0, 0)); BitmapFrame thumbnail = BitmapFrame.Create(target); BitmapFrame newPhoto = Resize(thumbnail, width, height, mode); return newPhoto; }
public static void SetSettingsFromConfig(iniparser parser) { // locations in MJ's laptop //Point p1 = new Point(120, 382); locations.Add(p1); //Point p2 = new Point(140, 420); locations.Add(p2); //Point p3 = new Point(290, 230); locations.Add(p3); //Point p4 = new Point(400, 300); locations.Add(p4); //Point p5 = new Point(405, 480); locations.Add(p5); //Point p6 = new Point(480, 595); locations.Add(p6); //Point p7 = new Point(515, 690); locations.Add(p7); //Point p8 = new Point(465, 755); locations.Add(p8); //Point p9 = new Point(415, 755); locations.Add(p9); //Point p10 = new Point(180, 545); locations.Add(p10); //Point p11 = new Point(150, 570); locations.Add(p11); // Locations (in tabletop) Point p1 = new Point(parser.GetValue("Locations", "P1X", 0), parser.GetValue("Locations", "P1Y", 0)); locations.Add(p1); Point p2 = new Point(parser.GetValue("Locations", "P2X", 0), parser.GetValue("Locations", "P2Y", 0)); locations.Add(p2); Point p3 = new Point(parser.GetValue("Locations", "P3X", 0), parser.GetValue("Locations", "P3Y", 0)); locations.Add(p3); Point p4 = new Point(parser.GetValue("Locations", "P4X", 0), parser.GetValue("Locations", "P4Y", 0)); locations.Add(p4); Point p5 = new Point(parser.GetValue("Locations", "P5X", 0), parser.GetValue("Locations", "P5Y", 0)); locations.Add(p5); Point p6 = new Point(parser.GetValue("Locations", "P6X", 0), parser.GetValue("Locations", "P6Y", 0)); locations.Add(p6); Point p7 = new Point(parser.GetValue("Locations", "P7X", 0), parser.GetValue("Locations", "P7Y", 0)); locations.Add(p7); Point p8 = new Point(parser.GetValue("Locations", "P8X", 0), parser.GetValue("Locations", "P8Y", 0)); locations.Add(p8); Point p9 = new Point(parser.GetValue("Locations", "P9X", 0), parser.GetValue("Locations", "P9Y", 0)); locations.Add(p9); Point p10 = new Point(parser.GetValue("Locations", "P10X", 0), parser.GetValue("Locations", "P10Y", 0)); locations.Add(p10); Point p11 = new Point(parser.GetValue("Locations", "P11X", 0), parser.GetValue("Locations", "P11Y", 0)); locations.Add(p11); //Point p1 = new Point(parser.GetValue("Locations", "P1X", 800), parser.GetValue("Locations", "P1Y", 1383)); locations.Add(p1); //Point p2 = new Point(parser.GetValue("Locations", "P2X", 925), parser.GetValue("Locations", "P2Y", 1499)); locations.Add(p2); //Point p3 = new Point(parser.GetValue("Locations", "P3X", 1795), parser.GetValue("Locations", "P3Y", 844)); locations.Add(p3); //Point p4 = new Point(parser.GetValue("Locations", "P4X", 2437), parser.GetValue("Locations", "P4Y", 1077)); locations.Add(p4); //Point p5 = new Point(parser.GetValue("Locations", "P5X", 2457), parser.GetValue("Locations", "P5Y", 1711)); locations.Add(p5); //Point p6 = new Point(parser.GetValue("Locations", "P6X", 2921), parser.GetValue("Locations", "P6Y", 2111)); locations.Add(p6); //Point p7 = new Point(parser.GetValue("Locations", "P7X", 3120), parser.GetValue("Locations", "P7Y", 2430)); locations.Add(p7); //Point p8 = new Point(parser.GetValue("Locations", "P8X", 2837), parser.GetValue("Locations", "P8Y", 2670)); locations.Add(p8); //Point p9 = new Point(parser.GetValue("Locations", "P9X", 2533), parser.GetValue("Locations", "P9Y", 2668)); locations.Add(p9); //Point p10 = new Point(parser.GetValue("Locations", "P10X", 1151), parser.GetValue("Locations", "P10Y", 1931)); locations.Add(p10); //Point p11 = new Point(parser.GetValue("Locations", "P11X", 969), parser.GetValue("Locations", "P11Y", 2016)); locations.Add(p11); location_dot_diameter = parser.GetValue("Locations", "location_dot_diameter", 55); location_dot_color = parser.GetValue("Locations", "location_dot_color", Brushes.Crimson); location_dot_outline_color = parser.GetValue("Locations", "location_dot_outline_color", Brushes.Crimson); location_dot_font_color = parser.GetValue("Locations", "location_dot_font_color", Brushes.White); // General variables //line_break = parser.GetValue("General", "line_break", "\r\n"); log_file = parser.GetValue("General", "log_file", "log.txt"); contribution_comment_date = parser.GetValue("General", "contribution_comment_date", "Taken by: "); contribution_comment_tag = parser.GetValue("General", "contribution_comment_tag", "Tags: "); contribution_comment_location = parser.GetValue("General", "contribution_comment_location", "Location "); designidea_date_desc = parser.GetValue("General", "designidea_date_desc", "Last Update: "); designidea_num_desc = parser.GetValue("General", "designidea_num_desc", "Comments"); users_date_desc = parser.GetValue("General", "users_date_desc", "Last Update: "); users_num_desc = parser.GetValue("General", "users_num_desc", "Contributions"); users_no_date = parser.GetValue("General", "users_no_date", "Just Created"); activities_date_desc = parser.GetValue("General", "activities_date_desc", "Last Update: "); activities_num_desc = parser.GetValue("General", "activities_num_desc", "Contributions"); frame_title = parser.GetValue("General", "frame_title", "Observations"); // Parameters high_contrast = parser.GetValue("Parameters", "high_contrast", false); top_most = parser.GetValue("Parameters", "top_most", false); show_update_label = parser.GetValue("Parameters", "show_update_label", false); response_to_mouse_clicks = parser.GetValue("Parameters", "response_to_mouse_clicks", true); enable_single_rotation = parser.GetValue("Parameters", "enable_single_rotation", true); max_num_content_update = parser.GetValue("Parameters", "max_num_content_update", 12); max_signup_frame = parser.GetValue("Parameters", "max_signup_frame", 5); max_collection_frame = parser.GetValue("Parameters", "max_collection_frame", 10); max_image_display_frame = parser.GetValue("Parameters", "max_image_display_frame", 10); max_design_ideas_frame = parser.GetValue("Parameters", "max_design_ideas_frame", 10); max_activity_frame = parser.GetValue("Parameters", "max_activity_frame", 10); max_thread_reply = parser.GetValue("Parameters", "max_thread_reply", 3); max_activity_frame_title_chars = parser.GetValue("Parameters", "max_activity_frame_title_chars", 10); //thumbnail_pixel_width = parser.GetValue("Parameters", "thumbnail_pixel_width",100); thumbnail_pixel_height = parser.GetValue("Parameters", "thumbnail_pixel_height", 100); thumbnail_video_span = new TimeSpan(0, 0, parser.GetValue("Parameters", "thumbnail_video_span_seconds", 2)); use_existing_thumbnails = parser.GetValue("Parameters", "use_existing_thumbnails", true); drag_dy_dx_factor = parser.GetValue("Parameters", "drag_dy_dx_factor", 2.1); //drag_dx_dy_factor = parser.GetValue("Parameters", "drag_dx_dy_factor",1.0); drag_collection_theta = parser.GetValue("Parameters", "drag_collection_theta", 5); scroll_scale_factor = parser.GetValue("Parameters", "scroll_scale_factor", 5); min_touch_points = parser.GetValue("Parameters", "min_touch_points", 2); max_consecutive_drag_points = parser.GetValue("Parameters", "max_consecutive_drag_points", 5); tap_error = parser.GetValue("Parameters", "tap_error", 5); manipulation_pivot_radius = parser.GetValue("Parameters", "manipulation_pivot_radius", 20.0); use_avatar_drag = parser.GetValue("Parameters", "use_avatar_drag", false); tab_width_percentage = parser.GetValue("Parameters", "tab_width_percentage", 17); manual_scroll = parser.GetValue("Parameters", "manual_scroll", false); manual_tap = parser.GetValue("Parameters", "manual_tap", false); right_panel_drag = parser.GetValue("Parameters", "right_panel_drag", true); whole_item_drag = parser.GetValue("Parameters", "whole_item_drag", false); center_commentarea_and_keyboard = parser.GetValue("Parameters", "center_commentarea_and_keyboard", false); multi_keyboard = parser.GetValue("Parameters", "multi_keyboard", false); show_vertical_drag = parser.GetValue("Parameters", "show_vertical_drag", true); show_empty_metadata = parser.GetValue("Parameters", "show_empty_metadata", false); show_all_metadata = parser.GetValue("Parameters", "show_all_metadata", false); use_list_refresher = parser.GetValue("Parameters", "use_list_refresher", false); update_period_ms = parser.GetValue("Parameters", "update_period_ms", 20000); scaling_mode = parser.GetValue("Parameters", "scaling_mode", BitmapScalingMode.Fant); click_opacity_on_collection_item = parser.GetValue("Parameters", "click_opacity_on_collection_item", 0.8); // Google Drive googledrive_directory_id = parser.GetValue("GoogleDrive", "googledrive_directory_id", "0B9mU-w_CpbztUUxtaXVIeE9SbWM"); googledrive_client_id = parser.GetValue("GoogleDrive", "googledrive_client_id", "333780750675-ag76kpq3supbbqi3v92vn3ejil8ght23.apps.googleusercontent.com"); googledrive_client_secret = parser.GetValue("GoogleDrive", "googledrive_client_secret", "bCYIAfrAC0i-qIfl0cLRnhwn"); googledrive_storage = parser.GetValue("GoogleDrive", "googledrive_storage", "gdrive_uploader"); googledrive_key = parser.GetValue("GoogleDrive", "googledrive_key", "z},drdzf11x9;87"); googledrive_refresh_token = parser.GetValue("GoogleDrive", "googledrive_refresh_token", "1/jpJHu8br2TnnM5hwCqgFe-yagf6zixlDZrlUvdXZ9s8"); googledrive_lastchange = parser.GetValue("GoogleDrive", "googledrive_lastchange", configurations.googledrive_lastchange); googledrive_userfilename = parser.GetValue("GoogleDrive", "googledrive_userfilename", "Users.txt"); googledrive_userfiletitle = parser.GetValue("GoogleDrive", "googledrive_userfiletitle", "Users"); googledrive_ideafilename = parser.GetValue("GoogleDrive", "googledrive_ideafilename", "Ideas.txt"); googledrive_ideafiletitle = parser.GetValue("GoogleDrive", "googledrive_ideafiletitle", "Ideas"); download_buffer_size = parser.GetValue("GoogleDrive", "download_buffer_size", 10240); // 10KB = 10 * 1024 // Paths image_path = parser.GetValue("Paths", "image_path", ".\\images\\"); avatar_path = parser.GetValue("Paths", "avatar_path", ".\\images\\avatars\\"); thumbnails_path = parser.GetValue("Paths", "thumbnails_path", ".\\images\\thumbnails\\"); contributions_path = parser.GetValue("Paths", "contributions_path", ".\\images\\contributions\\"); // Files background_pic = parser.GetValue("Files", "background_pic", "background.png"); drop_avatar_pic = parser.GetValue("Files", "drop_avatar_pic", "drop_avatar.png"); loading_image_pic = parser.GetValue("Files", "loading_image_pic", "loading_image.png"); empty_image_pic = parser.GetValue("Files", "empty_image_pic", "empty_image.png"); not_found_image_pic = parser.GetValue("Files", "not_found_image_pic", "not_found_image.png"); sound_image_pic = parser.GetValue("Files", "sound_image_pic", "sound_image.png"); video_image_pic = parser.GetValue("Files", "video_image_pic", "film.png"); keyboard_pic = parser.GetValue("Files", "keyboard_pic", "NN_Keyboard_v2.png"); keyboard_shift_pic = parser.GetValue("Files", "keyboard_shift_pic", "NN_Keyboard_v2_shift.png"); keyboard_caps_pic = parser.GetValue("Files", "keyboard_caps_pic", "NN_Keyboard_v2_caps.png"); keyboard_numpad_pic = parser.GetValue("Files", "keyboard_numpad_pic", "NN_Numpad.png"); close_icon = parser.GetValue("Files", "close_icon", "close.png"); change_view_list_icon = parser.GetValue("Files", "change_view_list_icon", "change_view_list.png"); change_view_stack_icon = parser.GetValue("Files", "change_view_stack_icon", "change_view_stack.png"); collection_window_icon = parser.GetValue("Files", "collection_window_icon", "collection_window_icon.png"); signup_icon = parser.GetValue("Files", "signup_icon", "signup.png"); signup_window_icon = parser.GetValue("Files", "signup_window_icon", "signup_window_icon.png"); submit_idea_icon = parser.GetValue("Files", "submit_idea_icon", "submit_idea.png"); thumbs_up_icon = parser.GetValue("Files", "thumbs_up_icon", "tu.jpg"); thumbs_down_icon = parser.GetValue("Files", "thumbs_down_icon", "td.jpg"); drag_icon = parser.GetValue("Files", "drag_icon", "drag.png"); drag_vertical_icon = parser.GetValue("Files", "drag_vertical_icon", "drag_vertical.png"); comment_icon = parser.GetValue("Files", "comment_icon", "comment.png"); reply_icon = parser.GetValue("Files", "reply_icon", "reply.png"); keyboard_click_wav = parser.GetValue("Files", "keyboard_click_wav", "click.wav"); // Frame frame_width = parser.GetValue("Frame", "frame_width", 300); frame_title_bar_height = parser.GetValue("Frame", "frame_title_bar_height", 40); frame_icon_width = parser.GetValue("Frame", "frame_icon_width", 40); // Item toolbar_item_width = parser.GetValue("Item", "toolbar_item_width", 30); }
public static BitmapFrame GetBitmapFrame(BitmapFrame photo, int width, int height, BitmapScalingMode mode) { TransformedBitmap target = new TransformedBitmap( photo, new ScaleTransform( width / photo.Width * 96 / photo.DpiX, height / photo.Height * 96 / photo.DpiY, 0, 0)); BitmapFrame thumbnail = BitmapFrame.Create(target); BitmapFrame newPhoto = Resize(thumbnail, width, height, mode); return(newPhoto); }
private static BitmapFrame Resize(BitmapFrame photo, int width, int height, BitmapScalingMode scalingMode = BitmapScalingMode.Fant) { // This is a more flexible, albiet slower alternative to FastResize. For more info: // http://weblogs.asp.net/bleroy/archive/2009/12/10/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi.aspx var group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(photo, new Rect(0, 0, width, height))); var targetVisual = new DrawingVisual(); DrawingContext targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); var target = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); return BitmapFrame.Create(target); }
/// <summary> /// Set this render holder bitmap scling mode. /// <para> /// Because when the rendering hosts are different, the rendering quality may be different /// </para> /// </summary> /// <param name="mode">The bitmap scaling mode</param> public void SetBitmapScalingMode(BitmapScalingMode mode) { RenderOptions.SetBitmapScalingMode(renderHolder, mode); }
public static ImageSource ScaleLogicalImageForDeviceSize(ImageSource image, Size deviceImageSize, BitmapScalingMode scalingMode) { return(Instance.ScaleLogicalImageForDeviceSize(image, deviceImageSize, scalingMode)); }
public void LoadData(Brush brushs) { brush = brushs; BitmapScalingMode scalingMode = RenderOptions.GetBitmapScalingMode(cont); if ((int)scalingMode == 2) { ComboBox_Quality.SelectedIndex = 0; } if ((int)scalingMode == 1) { ComboBox_Quality.SelectedIndex = 1; } if ((int)scalingMode == 3) { ComboBox_Quality.SelectedIndex = 2; } if (brushs is SolidColorBrush) { if (brushs == null || brushs.ToString() == "#00FFFFFF") { Rect_BackColor.Fill = null; } else { Rect_BackColor.Fill = (SolidColorBrush)brushs; } } else if (brushs is ImageBrush) { if (((ImageBrush)brushs).ImageSource != null) { R_ImageFill.Fill = new ImageBrush(((ImageBrush)brushs).ImageSource); ((ImageBrush)R_ImageFill.Fill).Stretch = Stretch.UniformToFill; ComboBox_Stretch.SelectedIndex = (int)((ImageBrush)brushs).Stretch; TabControlFill.SelectedIndex = 1; if (((ImageBrush)brush).RelativeTransform != null && ((ImageBrush)brush).RelativeTransform is TransformGroup) { TransformGroup transformGroup = ((TransformGroup)((ImageBrush)brush).RelativeTransform); CB_TileMode.SelectedIndex = (int)((ImageBrush)brushs).TileMode; TextBox_RotationAngle.Text = "" + ((RotateTransform)transformGroup.Children[0]).Angle; rotationbutton.SetAngleToPointer(((RotateTransform)transformGroup.Children[0]).Angle); TB_SCW.Text = "" + ((ScaleTransform)transformGroup.Children[1]).ScaleX; TB_SCH.Text = "" + ((ScaleTransform)transformGroup.Children[1]).ScaleY; TB_MVX.Text = "" + ((TranslateTransform)transformGroup.Children[2]).X; TB_MVY.Text = "" + ((TranslateTransform)transformGroup.Children[2]).Y; } } } else if (brushs is LinearGradientBrush) { RadioButton_LinearGradient.IsChecked = true; RadioButton_RadialGradient.IsChecked = false; Rect_StartColor.Fill = new SolidColorBrush(((LinearGradientBrush)brushs).GradientStops[0].Color); Rect_EndColor.Fill = new SolidColorBrush(((LinearGradientBrush)brushs).GradientStops[1].Color); TabControlFill.SelectedIndex = 2; } else if (brushs is RadialGradientBrush) { RadioButton_RadialGradient.IsChecked = true; RadioButton_LinearGradient.IsChecked = false; Rect_StartColor.Fill = new SolidColorBrush(((RadialGradientBrush)brushs).GradientStops[0].Color); Rect_EndColor.Fill = new SolidColorBrush(((RadialGradientBrush)brushs).GradientStops[1].Color); TabControlFill.SelectedIndex = 2; } }
/// <summary> /// Writes the attached property BitmapScalingMode to the given object. /// </summary> public static void SetBitmapScalingMode(DependencyObject target, BitmapScalingMode bitmapScalingMode) { if (target == null) { throw new ArgumentNullException("target"); } target.SetValue(BitmapScalingModeProperty, bitmapScalingMode); }
private static BitmapFrame Rotate(BitmapFrame photo, double angle, BitmapScalingMode mode) { TransformedBitmap target = new TransformedBitmap( photo, new RotateTransform(angle, photo.PixelWidth / 2, photo.PixelHeight / 2)); BitmapFrame thumbnail = BitmapFrame.Create(target); BitmapFrame newPhoto = Resize(thumbnail, photo.PixelWidth, photo.PixelHeight, mode); return newPhoto; }
public static void SetBitmapScalingMode(System.Windows.DependencyObject target, BitmapScalingMode bitmapScalingMode) { }
public static BitmapSource ResizeBitmapSource(BitmapSource bmpSrc, int width, int height, BitmapScalingMode scalingMode) { DrawingGroup group = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(group, scalingMode); group.Children.Add(new ImageDrawing(bmpSrc, new Rect(0, 0, width, height))); DrawingVisual targetVisual = new DrawingVisual(); DrawingContext targetContext = targetVisual.RenderOpen(); targetContext.DrawDrawing(group); RenderTargetBitmap target = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default); targetContext.Close(); target.Render(targetVisual); target.Freeze(); return target; }
private static BitmapFrame GetBitmapFrame(MemoryStream original, int width, int height, BitmapScalingMode mode) { BitmapDecoder photoDecoder = BitmapDecoder.Create(original, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None); BitmapFrame photo = photoDecoder.Frames[0]; TransformedBitmap target = new TransformedBitmap( photo, new ScaleTransform( width / photo.Width * 96 / photo.DpiX, height / photo.Height * 96 / photo.DpiY, 0, 0)); BitmapFrame thumbnail = BitmapFrame.Create(target); BitmapFrame newPhoto = Resize(thumbnail, width, height, mode); return(newPhoto); }
public static void SetSmallImageScalingMode(DependencyObject obj, BitmapScalingMode value) { obj.SetValue(SmallImageScalingModeProperty, value); }