public static byte[] GetImage(this byte[] input, int width, int height, SizeMode mode) { using (var source = new MemoryStream(input)) { return(GetImage(source, width, height, mode)); } }
public ImageViewer() { InitializeComponent(); _sizeMode = SizeMode.RatioStretch; this.AutoScroll = (_sizeMode == SizeMode.Scrollable); }
public void DrawImage(Pixbuf image, RectangleD layout, RectangleD imagePart, SizeMode sizeMode = SizeMode.Fit) { double x = layout.X * drawingScaleX; double y = layout.Y * drawingScaleY; double width = layout.Width * drawingScaleX; double height = layout.Height * drawingScaleY; if (width.IsZero() || height.IsZero()) { return; } double scaleX = width / imagePart.Width; double scaleY = height / imagePart.Height; using (Pixbuf pbCropped = new Pixbuf(Colorspace.Rgb, true, 8, (int)imagePart.Width, (int)imagePart.Height)) { image.CopyArea((int)imagePart.X, (int)imagePart.Y, (int)imagePart.Width, (int)imagePart.Height, pbCropped, 0, 0); using (Pixbuf pbScaled = new Pixbuf(Colorspace.Rgb, true, 8, (int)width, (int)height)) { pbCropped.Scale(pbScaled, 0, 0, pbScaled.Width, pbScaled.Height, 0, 0, scaleX, scaleY, InterpType.Hyper); CairoHelper.SetSourcePixbuf(cairoContext, pbScaled, x, y); cairoContext.Paint(); } } }
internal static void SizeEnabledSetter(object value, IPropertyBag propertyBag) { int num = (int)propertyBag[ReceiveConnectorSchema.ProtocolOptions]; SizeMode sizeMode = (SizeMode)value; bool flag; bool flag2; if (sizeMode == SizeMode.Disabled) { flag = false; flag2 = false; } else if (sizeMode == SizeMode.EnabledWithoutValue) { flag = true; flag2 = true; } else { flag = true; flag2 = false; } num = (flag ? (num | 1) : (num & -2)); propertyBag[ReceiveConnectorSchema.ProtocolOptions] = (flag2 ? (num | 2) : (num & -3)); }
public void UpdateSize(SizeMode mode) { try { SelfSize = 0; if (mode == SizeMode.Managed || mode == SizeMode.Total) { SelfSize += CalculateSelfManagedSize(); } if (mode == SizeMode.Native || mode == SizeMode.Total) { SelfSize += CalculateSelfNativeSize(); } TotalSize = SelfSize; if (Children == null) { return; } foreach (var child in Children) { child.UpdateSize(mode); TotalSize += child.TotalSize; } Children.Sort(); } finally { TypeStats.RegisterItem(this); } }
private void panelPicture_MouseUp(object sender, MouseEventArgs e) { if (e.Button == ZoomMouseButton) { float newZoom; if ((Control.ModifierKeys & ZoomOutModifier) != Keys.None) { newZoom = getNextZoomValue(ZoomMode.Out); } else { newZoom = getNextZoomValue(ZoomMode.In); } sizeMode = SizeMode.Zoom; calculateRect(e.Location, newZoom); this.panelPicture.Invalidate(); } else if (e.Button == DragMouseButton) { if (UseZoomCursors && ZoomMouseButton != MouseButtons.None && ZoomInCursor != null && ZoomOutCursor != null) { this.Cursor = new Cursor(ZoomInCursor.Handle); } else { this.Cursor = defaultCursor; } } }
public static void PaintBackground( Graphics graphics, Bitmap background, Size size, Rectangle bounds, HorizontalAlignment hAlignment, SizeMode sizeXMode, VerticalAlignment vAlignment, SizeMode sizeYMode, Control parent, Color filterColor) { PaintBackground( graphics, background, size, bounds, hAlignment, sizeXMode, vAlignment, sizeYMode, false, 0, 0, 0, 0, 0, 0, 0, 0, parent, filterColor); }
public override void CreateFromTemplate(XElement node, Hashtable boundFields) { base.CreateFromTemplate(node, boundFields); XAttribute attr = node.Attribute("resource"); if (attr != null) { Resource = attr.Value; } attr = node.Attribute("fileName"); if (attr != null) { FileName = attr.Value; } attr = node.Attribute("sizeMode"); SizeMode value; if (attr != null && Enum.TryParse(attr.Value, true, out value)) { sizeMode = value; } RefreshBoundFields(boundFields); }
/// <summary> /// Initializes a new instance of the <see cref="SizeProperty"/> class. /// </summary> /// <param name="_sizeMode">size mode.</param> /// <param name="_name">property name</param> /// <param name="_targets">property targets</param> /// <param name="_satXPoints">x points of the satisfaction linear spline</param> /// <param name="_satYPoints">y points of the satisfaction linear spline</param> public CLSizeProperty(SizeMode _sizeMode, string _name, List <CLTarget> _targets, List <float> _satXPoints, List <float> _satYPoints) : base(_name, _targets) { satFunction = new CLLinearSplineSatFunction(_satXPoints, _satYPoints); sizeType = _sizeMode; cost = 1.0f; }
public void TestSerializationIosSimulator() { Uri url = new Uri("https://another.url.co.il"); Uri stitchingServiceUrl = new Uri("https://another.stitchingserviceuri.co.il"); RGridDom dom = new RGridDom(); Dictionary <string, RGridResource> resources = new Dictionary <string, RGridResource>(); SizeMode target = SizeMode.FullPage; VisualGridSelector selector = null; System.Drawing.Rectangle region = new System.Drawing.Rectangle(40, 50, 60, 70); IosDeviceInfo deviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_XR, ScreenOrientation.Landscape, IosVersion.ONE_VERSION_BACK); RenderInfo renderInfo = new RenderInfo(0, 0, target, selector, region, null, deviceInfo); VisualGridSelector[] selectorsToFindRegionsFor = new VisualGridSelector[0]; bool sendDom = true; RenderBrowserInfo browserInfo = new RenderBrowserInfo(deviceInfo); RenderRequest request = new RenderRequest("id", null, url, stitchingServiceUrl, dom, resources, renderInfo, browserInfo.Platform, browserInfo.BrowserType, null, selectorsToFindRegionsFor, sendDom, null, null, null); JsonSerializerSettings settings = JsonUtils.CreateSerializerSettings(); settings.Formatting = Formatting.Indented; string json = JsonConvert.SerializeObject(request, settings); string expectedJson = CommonUtils.ReadResourceFile("Test.Eyes.Sdk.Core.DotNet.Resources.TestRenderRequestSerializationIosDevice.json"); Assert.AreEqual(expectedJson, json); }
private static int GetProcessOrder(SizeMode sizeMode) { return(sizeMode switch { SizeMode.Fixed => 0, SizeMode.SizeToContent => 1, SizeMode.Star => 2, _ => throw new InvalidOperationException($"Unknown size mode {sizeMode}") });
public void Save(XmlDocument doc) { Config.SafeNodeSelect(doc, "/Settings/Display/AutoRotate", AutoRotate.ToString()); Config.SafeNodeSelect(doc, "/Settings/Display/CheckeredPatternBackground", CheckeredPatternBackground.ToString()); Config.SafeNodeSelect(doc, "/Settings/Display/Zoom", Zoom.ToString()); Config.SafeNodeSelect(doc, "/Settings/Display/ZoomStep", SizeMode.ToString()); Config.SafeNodeSelect(doc, "/Settings/Display/SizeMode", SizeMode.ToString()); Config.SafeNodeSelect(doc, "/Settings/Display/SizeModeOnImageLoad", SizeModeOnImageLoad.ToString()); }
public static byte[] GetImage(this Image input, int width, int height, SizeMode mode) { using (var output = new MemoryStream()) { SaveImageTo(input, output, width, height, mode, Color.White); return(output.ToArray()); } }
/// <summary> /// Creates a new radial gradient. /// </summary> /// <param name="circle">Determines if the radial gradient has to be forced to a circle form.</param> /// <param name="center">The center point of the gradient.</param> /// <param name="width">The width of the ellipsoid.</param> /// <param name="height">The height of the ellipsoid.</param> /// <param name="sizeMode">The size mode of the ellipsoid.</param> /// <param name="stops">A collection of stops to use.</param> /// <param name="repeating">The repeating setting.</param> public CssRadialGradientValue(Boolean circle, Point center, ICssValue width, ICssValue height, SizeMode sizeMode, CssGradientStopValue[] stops, Boolean repeating = false) { _stops = stops; _center = center; _width = width; _height = height; _repeating = repeating; _circle = circle; _sizeMode = sizeMode; }
/// <summary> /// Creates a new radial gradient. /// </summary> /// <param name="circle">Determines if the radial gradient has to be forced to a circle form.</param> /// <param name="pt">The center point of the gradient.</param> /// <param name="width">The width of the ellipsoid.</param> /// <param name="height">The height of the ellipsoid.</param> /// <param name="sizeMode">The size mode of the ellipsoid.</param> /// <param name="stops">A collection of stops to use.</param> /// <param name="repeating">The repeating setting.</param> public RadialGradient(Boolean circle, Point pt, Length width, Length height, SizeMode sizeMode, GradientStop[] stops, Boolean repeating = false) { _stops = stops; _pt = pt; _width = width; _height = height; _repeating = repeating; _circle = circle; _sizeMode = sizeMode; }
public BackgroundedPanel() : base() { filterColor = Color.Transparent; sizeXMode = SizeMode.None; sizeYMode = SizeMode.None; hAlignment = HorizontalAlignment.Center; vAlignment = VerticalAlignment.Center; sizeToBackground = false; adapt = false; }
public RenderInfo(int width, int height, SizeMode target, VisualGridSelector selector, Rectangle?region, EmulationBaseInfo emulationInfo, IosDeviceInfo iosDeviceInfo) { Width = width; Height = height; Target = target; Selector = selector; Region = region; EmulationInfo = emulationInfo; IosDeviceInfo = iosDeviceInfo; }
public RadialGradient(bool circle, Point pt, Length width, Length height, SizeMode sizeMode, GradientStop[] stops, bool repeating = false) { _stops = stops; Position = pt; MajorRadius = width; MinorRadius = height; IsRepeating = repeating; IsCircle = circle; Mode = sizeMode; }
protected OlapAxisLayoutSerializer() { EmptyDataString = string.Empty; CurrencyFormatString = OlapControl.__CurrencyFormatString; AxesLayout = new SerializedLayout(); SizeMode = SizeMode.Increase; _analysisType = AnalysisType.Grid; _AnalysisTypeWasset = false; SuppressSaveOLAPSlices = false; }
public Rectangle GetSizePixels(SizeMode sizeMode) { switch (sizeMode) { case SizeMode.Local: return(GetLocalSizePixels()); case SizeMode.Full: return(GetFullMapSizePixels()); case SizeMode.Auto: return(GetAutoSizePixels()); } return(Rectangle.Empty); }
public PrintSize(IStreamReader reader, RecordType id, ushort length) : base(reader, id, length) { // assert that the correct record type is instantiated Debug.Assert(this.Id == ID); // initialize class members from stream this.printSize = (SizeMode)reader.ReadUInt16(); // assert that the correct number of bytes has been read from the stream Debug.Assert(this.Offset + this.Length == this.Reader.BaseStream.Position); }
public static void ChangeWindowSize(SizeMode value, bool needSave = true) { if (CurrentWindowSize != value) { windowSize = value; if (needSave) { SaveCurrentPreferences(); } var mainForm = GetMainForm(); // Check whether app has been ready if (mainForm != null) { if (CurrentWindowSize == SizeMode.FullScreen) { // Full-size mode System.Drawing.Rectangle screen = System.Windows.Forms.Screen.FromControl(mainForm).WorkingArea; mainForm.Size = screen.Size; mainForm.DesktopLocation = new Point(0, 0); } else { Size size; switch (CurrentWindowSize) { case SizeMode._1024x768: size = new Size(1024, 768); break; case SizeMode._1366x768: size = new Size(1366, 768); break; case SizeMode._1680x1050: size = new Size(1680, 1050); break; default: throw new ArgumentOutOfRangeException(); } // Change state to normal (not maximized) mainForm.WindowState = System.Windows.Forms.FormWindowState.Normal; // Re-position System.Drawing.Rectangle screen = System.Windows.Forms.Screen.FromControl(mainForm).WorkingArea; mainForm.DesktopLocation = new Point((screen.Width - size.Width) / 2, (screen.Height - size.Height) / 2); // Change size mainForm.Size = size; } } } }
// Use this for initialization void Start() { FPlatform.InitializeMainThreadID(); // for DebugUtil.EmitDebug() mainCanvas = GameObject.Find("UICanvas").GetComponent <Canvas>(); trackButton = GameObject.Find("TrackButton").GetComponent <Button>(); trackButton.onClick.AddListener(track_click); resetButton = GameObject.Find("ResetButton").GetComponent <Button>(); resetButton.onClick.AddListener(reset_click); sizeButton = GameObject.Find("SizeButton").GetComponent <Button>(); sizeButton.onClick.AddListener(size_click); curSize = SizeMode.cm_2; gsGlobal.GridSize = 0.02f; sizeButton.GetComponentInChildren <Text>().text = "2cm"; viewDropDown = GameObject.Find("ViewModeDropDown").GetComponent <Dropdown>(); viewDropDown.onValueChanged.AddListener(view_changed); debugText = GameObject.Find("DebugText").GetComponent <Text>(); debugText.text = ""; GameObject.Find("DebugTextCloseButton").GetComponent <Button>().onClick.AddListener(hide_error_text); debugText.gameObject.SetVisible(false); gsGlobal.TextErrorHandlerF = set_error_text; GameObject simulateButtonGO = UnityUtil.FindGameObjectByName("SimulateButton"); if (FPlatform.InUnityEditor()) { simulateButtonGO.SetVisible(true); simulateButtonGO.GetComponent <Button>().onClick.AddListener(simulate_ar); } optionsButton = GameObject.Find("OptionsButton").GetComponent <Button>(); optionsButton.onClick.AddListener(options_click); UnityUtil.FindGameObjectByName("OptionSaveARStream").GetComponent <Toggle>(). onValueChanged.AddListener(option_savearstream_changed); UnityUtil.FindGameObjectByName("OptionSaveVideoStream").GetComponent <Toggle>(). onValueChanged.AddListener(option_save_video_stream_changed); qualityDropDown = UnityUtil.FindGameObjectByName("OptionQualityDropDown").GetComponent <Dropdown>(); qualityDropDown.onValueChanged.AddListener(on_quality_changed); optionsPanel = UnityUtil.FindGameObjectByName("OptionsPanel"); optionsPanel.SetVisible(false); }
private void InitializeOptions() { ImageExportSettings settings = ImageExportSettings.Default; _exportOption = (ExportOption)settings.SelectedImageExportOption; _selectedExporterInfo = GetExporterInfo(settings.SelectedImageExporterId); if (_selectedExporterInfo == null) { _selectedExporterInfo = _exporterInfoList[0]; } _sizeMode = settings.SizeMode; _backgroundColor = settings.BackgroundColor; }
/// <summary> /// Creates a new Texture based on a <see cref="Duality.Resources.Pixmap"/>. /// </summary> /// <param name="basePixmap">The <see cref="Duality.Resources.Pixmap"/> to use as source for pixel data.</param> /// <param name="sizeMode">Specifies behaviour in case the source data has non-power-of-two dimensions.</param> /// <param name="filterMag">The OpenGL filter mode for drawing the Texture bigger than it is.</param> /// <param name="filterMin">The OpenGL fitler mode for drawing the Texture smaller than it is.</param> /// <param name="wrapX">The OpenGL wrap mode on the texel x axis.</param> /// <param name="wrapY">The OpenGL wrap mode on the texel y axis.</param> /// <param name="format">The format in which OpenGL stores the pixel data.</param> public Texture(ContentRef <Pixmap> basePixmap, SizeMode sizeMode = SizeMode.Default, TextureMagFilter filterMag = TextureMagFilter.Linear, TextureMinFilter filterMin = TextureMinFilter.LinearMipmapLinear, TextureWrapMode wrapX = TextureWrapMode.ClampToEdge, TextureWrapMode wrapY = TextureWrapMode.ClampToEdge, PixelInternalFormat format = PixelInternalFormat.Rgba) { this.filterMag = filterMag; this.filterMin = filterMin; this.wrapX = wrapX; this.wrapY = wrapY; this.pixelformat = format; this.LoadData(basePixmap, sizeMode); }
public static byte[] GetImage(this Stream source, int width, int height, SizeMode mode, bool resetPosition = true) { using (var destination = new MemoryStream()) { if (resetPosition) { source.Position = 0; } SaveImageTo(source, destination, width, height, mode); destination.Position = 0; return(destination.GetBytes()); } }
public void BuildLayout() { DockMode = LayoutSetting.DockMode; SizeModeWidth = LayoutSetting.SizeModeWidth; SizeModeHeight = LayoutSetting.SizeModeHeight; // 기존 페이지 삭제 var pages = _pages.ToList(); foreach (var page in pages) { Controls.Remove(page); } // 페이지 등록 foreach (var srcPage in LayoutSetting.Pages) { var page = new Page(srcPage.PageName); page.Title = srcPage.Title; page.VisibleTitle = srcPage.VisibleTitle; page.VisibleBackButton = srcPage.VisibleBackButton; page.CloseMode = srcPage.CloseMode; // 해당 페이지의 아이템 등록 var srcPageItems = LayoutSetting.PageItems.Where(o => o.PageName == srcPage.PageName).ToList(); foreach (var srcItem in srcPageItems) { var item = page.AddItemAfterCopy(srcItem); if (item == null) { continue; } item.OnFolderClickEvent += PageItemFolderClick; } Controls.Add(page); } var main = _pages.FirstOrDefault(o => o.PageName == "Main"); if (main != null) { main.BringToFront(); } LayoutSetting.Invalidate(this); }
private static int GetProcessOrder(SizeMode sizeMode) { switch (sizeMode) { case SizeMode.Fixed: return(0); case SizeMode.SizeToContent: return(1); case SizeMode.Star: return(2); default: throw new InvalidOperationException($"Unknown size mode {sizeMode}"); } }
/// <summary> /// Creates a new empty Texture with the specified size. /// </summary> /// <param name="width">The Textures width.</param> /// <param name="height">The Textures height</param> /// <param name="sizeMode">Specifies behaviour in case the specified size has non-power-of-two dimensions.</param> /// <param name="filterMag">The OpenGL filter mode for drawing the Texture bigger than it is.</param> /// <param name="filterMin">The OpenGL fitler mode for drawing the Texture smaller than it is.</param> /// <param name="wrapX">The OpenGL wrap mode on the texel x axis.</param> /// <param name="wrapY">The OpenGL wrap mode on the texel y axis.</param> /// <param name="format">The format in which OpenGL stores the pixel data.</param> public Texture(int width, int height, SizeMode sizeMode = SizeMode.Default, TextureMagFilter filterMag = TextureMagFilter.Linear, TextureMinFilter filterMin = TextureMinFilter.LinearMipmapLinear, TextureWrapMode wrapX = TextureWrapMode.ClampToEdge, TextureWrapMode wrapY = TextureWrapMode.ClampToEdge, PixelInternalFormat format = PixelInternalFormat.Rgba) { this.filterMag = filterMag; this.filterMin = filterMin; this.wrapX = wrapX; this.wrapY = wrapY; this.pixelformat = format; this.texSizeMode = sizeMode; this.AdjustSize(width, height); this.SetupOpenGLRes(); }
public static void CreateTiledImage(Graphics graphics, Bitmap image, SizeMode Tiling, Size ClientSize) { int maxWidth = ClientSize.Width, maxHeight = ClientSize.Height; if (Tiling != SizeMode.Repeat) { maxWidth = image.Width; maxHeight = image.Height; } for (int currentHeight = 0; currentHeight < maxHeight; currentHeight += image.Height) { for (int currentWidth = 0; currentWidth < maxWidth; currentWidth += image.Width) { graphics.DrawImage(image, currentWidth, currentHeight); } } }
/// <summary> /// Creates a new Texture based on a <see cref="Duality.Resources.Pixmap"/>. /// </summary> /// <param name="basePixmap">The <see cref="Duality.Resources.Pixmap"/> to use as source for pixel data.</param> /// <param name="sizeMode">Specifies behaviour in case the source data has non-power-of-two dimensions.</param> /// <param name="filterMag">The OpenGL filter mode for drawing the Texture bigger than it is.</param> /// <param name="filterMin">The OpenGL fitler mode for drawing the Texture smaller than it is.</param> /// <param name="wrapX">The OpenGL wrap mode on the texel x axis.</param> /// <param name="wrapY">The OpenGL wrap mode on the texel y axis.</param> /// <param name="format">The format in which OpenGL stores the pixel data.</param> public Texture(ContentRef<Pixmap> basePixmap, SizeMode sizeMode = SizeMode.Default, TextureMagFilter filterMag = TextureMagFilter.Linear, TextureMinFilter filterMin = TextureMinFilter.LinearMipmapLinear, TextureWrapMode wrapX = TextureWrapMode.ClampToEdge, TextureWrapMode wrapY = TextureWrapMode.ClampToEdge, PixelInternalFormat format = PixelInternalFormat.Rgba, PixelType pixelType = PixelType.UnsignedByte, bool keepPixmapDataResident = false) { this.filterMag = filterMag; this.filterMin = filterMin; this.wrapX = wrapX; this.wrapY = wrapY; this.pixelformat = format; this.pixelType = pixelType; this.keepPixmapDataResident = keepPixmapDataResident; this.LoadData(basePixmap, sizeMode); }
/// <summary> /// Represents different ways of specifying the width of a <see cref="Column"/>. /// </summary> /// <param name="value">The number of "star" units the width of a <see cref="Column"/> uses.</param> /// <param name="sizeMode">The size mode according to which a <see cref="Column"/> gets its width.</param> public ColumnWidth(double value, SizeMode sizeMode) : this() { this.Value = value; this.SizeMode = sizeMode; }
public void size(int width, int height, SizeMode sizeMode) { // FIXME: check sizeMode and reject some. Host.Width = width; Host.Height = height; }
public void size(int width, int height, SizeMode sizeMode) { // FIXME: check sizeMode and reject some. Host.SetViewport (width, height); }
private void SetSizeMode(SizeMode SizeMode) { paneImage.Box.SizeMode = SizeMode; // Reset zoom level. ZoomLevel = DefaultZoomLevel; UpdateImageStatus(); }
private void mnuStretch_Click(object sender, EventArgs e) { this.mucPicVwrRPlot.ImageSizeMode = SizeMode.RatioStretch; }
public static void Dispose() { m_UndoKey = null; m_sizeMode = SizeMode.Single; }
public static bool SupportsTransition(SizeMode mode) { switch (mode) { case SizeMode.FitToWindow: case SizeMode.FitToWindowLargeOnly: case SizeMode.StretchToWindow: return true; } return false; }
public void GeneratePreviewPack(PreviewMarkersType previewMarkers, SizeMode sizeMode, IniFile map, bool fixDimensions) { Logger.Info("Generating PreviewPack data"); // we will have to re-lock the BitmapData _drawingSurface.Lock(_drawingSurface.Bitmap.PixelFormat); if (MarkOreFields == false) { Logger.Trace("Marking ore and gems areas"); MarkOreAndGems(); Logger.Debug("Redrawing ore and gems areas"); RedrawOreAndGems(); } // undo tiled, if needed if (StartPosMarking == StartPositionMarking.Tiled) UndrawTiledStartPositions(); _drawingSurface.Unlock(); switch (previewMarkers) { case PreviewMarkersType.None: break; case PreviewMarkersType.Squared: DrawSquaredStartPositions(); break; case PreviewMarkersType.Bittah: case PreviewMarkersType.Aro: // to be injected later break; } // Number magic explained: http://modenc.renegadeprojects.com/Maps/PreviewPack int pw, ph; switch (Engine) { case EngineType.TiberianSun: pw = (int)Math.Ceiling((fixDimensions ? 1.975 : 2.000) * FullSize.Width); ph = (int)Math.Ceiling((fixDimensions ? 0.995 : 1.000) * FullSize.Height); break; case EngineType.Firestorm: pw = (int)Math.Ceiling((fixDimensions ? 1.975 : 2.000) * FullSize.Width); ph = (int)Math.Ceiling((fixDimensions ? 0.995 : 1.000) * FullSize.Height); break; case EngineType.RedAlert2: pw = (int)Math.Ceiling((fixDimensions ? 1.975 : 2.000) * FullSize.Width); ph = (int)Math.Ceiling((fixDimensions ? 0.995 : 1.000) * FullSize.Height); break; case EngineType.YurisRevenge: pw = (int)Math.Ceiling((fixDimensions ? 1.975 : 2.000) * LocalSize.Width); ph = (int)Math.Ceiling((fixDimensions ? 1.000 : 1.000) * LocalSize.Height); break; default: throw new ArgumentOutOfRangeException(); } using (var preview = new Bitmap(pw, ph, PixelFormat.Format24bppRgb)) { using (Graphics gfx = Graphics.FromImage(preview)) { // use high-quality scaling gfx.InterpolationMode = InterpolationMode.HighQualityBicubic; gfx.SmoothingMode = SmoothingMode.HighQuality; gfx.PixelOffsetMode = PixelOffsetMode.HighQuality; gfx.CompositingQuality = CompositingQuality.HighQuality; var srcRect = GetSizePixels(sizeMode); var dstRect = new Rectangle(0, 0, preview.Width, preview.Height); gfx.DrawImage(_drawingSurface.Bitmap, dstRect, srcRect, GraphicsUnit.Pixel); switch (previewMarkers) { case PreviewMarkersType.None: case PreviewMarkersType.Squared: break; case PreviewMarkersType.Bittah: DrawStartMarkersBittah(gfx, srcRect, dstRect); break; case PreviewMarkersType.Aro: DrawStartMarkersAro(gfx, srcRect, dstRect); break; } } Logger.Info("Injecting thumbnail into map"); ThumbInjector.InjectThumb(preview, map); // debug thing to dump original previewpack dimensions // preview.Save("C:\\thumbs\\" + Program.Settings.OutputFile + ".png"); // var originalPreview = ThumbInjector.ExtractThumb(this); /*var prev = GetSection("Preview"); if (prev != null) { var name = DetermineMapName(this.EngineType); var size = GetSection("Preview").ReadString("Size").Split(','); var previewSize = new Rectangle(int.Parse(size[0]), int.Parse(size[1]), int.Parse(size[2]), int.Parse(size[3])); File.AppendAllText("C:\\thumbs\\map_preview_dimensions.txt", string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\n", name, previewSize.Width, previewSize.Height, LocalSize.Width, LocalSize.Height, FullSize.Width, FullSize.Height)); }*/ } }
/// <summary> /// Creates a new PictureBox /// </summary> /// <param name="name">Control name</param> /// <param name="PositionWidthHeight">A rectangle that specifies the position, width , height relative to the control parent</param> /// <param name="image">Image to display</param> /// <param name="sizeMode">Optional,Sets image layout : Normal : the picture is displayed without resizing, StrechImage : the image is resized to fill the picture box, CenterImage : the image is centered in the PictureBox without resizing, The defualt is Normal</param> /// <param name="viewport">Optional : Viewport used to render the gui, if your game contains only one viewport pass null or don't pass anything at all.</param> public PictureBox(String name, Rectangle PositionWidthHeight, Texture2D image, SizeMode sizeMode = SizeMode.Normal, Viewport? viewport = null) : base(name,"",PositionWidthHeight,image,null,Color.Transparent,viewport) { // Set sizeMode & calculate source rectangle SizeMode = sizeMode; }
public Rectangle GetSizePixels(SizeMode sizeMode) { switch (sizeMode) { case SizeMode.Local: return GetLocalSizePixels(); case SizeMode.Full: return GetFullMapSizePixels(); case SizeMode.Auto: return GetAutoSizePixels(); } return Rectangle.Empty; }
public static SizeModeBehavior FromSizeMode(SizeMode mode) { switch (mode) { case SizeMode.FitToWindow: return FitToWindow.Instance; case SizeMode.FitToWindowLargeOnly: return FitToWindowLargeOnly.Instance; case SizeMode.ShowNativeSize: return ShowNativeSize.Instance; case SizeMode.StretchToWindow: return StretchToWindow.Instance; case SizeMode.FitToWindowWidth: return FitToWindowWidth.Instance; case SizeMode.FitToWindowHeight: return FitToWindowHeight.Instance; default: throw new ArgumentException("Invalid size mode: " + mode); } }
/// <summary> /// Creates a new Texture based on a <see cref="Duality.Resources.Pixmap"/>. /// </summary> /// <param name="basePixmap">The <see cref="Duality.Resources.Pixmap"/> to use as source for pixel data.</param> /// <param name="sizeMode">Specifies behaviour in case the source data has non-power-of-two dimensions.</param> /// <param name="filterMag">The OpenGL filter mode for drawing the Texture bigger than it is.</param> /// <param name="filterMin">The OpenGL fitler mode for drawing the Texture smaller than it is.</param> /// <param name="wrapX">The OpenGL wrap mode on the texel x axis.</param> /// <param name="wrapY">The OpenGL wrap mode on the texel y axis.</param> /// <param name="format">The format in which OpenGL stores the pixel data.</param> public Texture(ContentRef<Pixmap> basePixmap, SizeMode sizeMode = SizeMode.Default, TextureMagFilter filterMag = TextureMagFilter.Linear, TextureMinFilter filterMin = TextureMinFilter.LinearMipmapLinear, TextureWrapMode wrapX = TextureWrapMode.ClampToEdge, TextureWrapMode wrapY = TextureWrapMode.ClampToEdge, PixelInternalFormat format = PixelInternalFormat.Rgba) { this.filterMag = filterMag; this.filterMin = filterMin; this.wrapX = wrapX; this.wrapY = wrapY; this.pixelformat = format; this.LoadData(basePixmap, sizeMode); }
private void mnuScroll_Click(object sender, EventArgs e) { this.mucPicVwrRPlot.ImageSizeMode = SizeMode.Scrollable; }
/// <summary> /// Loads the specified <see cref="Duality.Resources.Pixmap">Pixmaps</see> pixel data. /// </summary> /// <param name="basePixmap">The <see cref="Duality.Resources.Pixmap"/> that is used as pixel data source.</param> /// <param name="sizeMode">Specifies behaviour in case the source data has non-power-of-two dimensions.</param> public void LoadData(ContentRef<Pixmap> basePixmap, SizeMode sizeMode) { DualityApp.GuardSingleThreadState(); if (this.glTexId == 0) this.glTexId = GL.GenTexture(); this.needsReload = false; this.basePixmap = basePixmap; this.texSizeMode = sizeMode; int lastTexId; GL.GetInteger(GetPName.TextureBinding2D, out lastTexId); GL.BindTexture(TextureTarget.Texture2D, this.glTexId); if (!this.basePixmap.IsExplicitNull) { Pixmap.Layer pixelData = null; Pixmap basePixmapRes = this.basePixmap.IsAvailable ? this.basePixmap.Res : null; if (basePixmapRes != null) { pixelData = basePixmapRes.MainLayer; this.atlas = basePixmapRes.Atlas != null ? basePixmapRes.Atlas.ToArray() : null; } if (pixelData == null) pixelData = Pixmap.Checkerboard.Res.MainLayer; this.AdjustSize(pixelData.Width, pixelData.Height); this.SetupOpenGLRes(); if (this.texSizeMode != SizeMode.NonPowerOfTwo && (this.pxWidth != this.texWidth || this.pxHeight != this.texHeight)) { if (this.texSizeMode == SizeMode.Enlarge) { Pixmap.Layer oldData = pixelData; pixelData = oldData.CloneResize(this.texWidth, this.texHeight); // Fill border pixels manually - that's cheaper than ColorTransparentPixels here. oldData.DrawOnto(pixelData, BlendMode.Solid, this.pxWidth, 0, 1, this.pxHeight, this.pxWidth - 1, 0); oldData.DrawOnto(pixelData, BlendMode.Solid, 0, this.pxHeight, this.pxWidth, 1, 0, this.pxHeight - 1); } else pixelData = pixelData.CloneRescale(this.texWidth, this.texHeight, Pixmap.FilterMethod.Linear); } // Load pixel data to video memory GL.TexImage2D(TextureTarget.Texture2D, 0, this.pixelformat, pixelData.Width, pixelData.Height, 0, GLPixelFormat.Rgba, PixelType.UnsignedByte, pixelData.Data); // Adjust atlas to represent UV coordinates if (this.atlas != null) { Vector2 scale; scale.X = this.uvRatio.X / this.pxWidth; scale.Y = this.uvRatio.Y / this.pxHeight; for (int i = 0; i < this.atlas.Length; i++) { this.atlas[i].X *= scale.X; this.atlas[i].W *= scale.X; this.atlas[i].Y *= scale.Y; this.atlas[i].H *= scale.Y; } } } else { this.atlas = null; this.AdjustSize(this.size.X, this.size.Y); this.SetupOpenGLRes(); } GL.BindTexture(TextureTarget.Texture2D, lastTexId); }
/// <summary> /// Represents different ways of specifying the width of a <see cref="Column"/>. /// </summary> /// <param name="sizeMode">The size mode according to which a <see cref="Column"/> gets its width.</param> public ColumnWidth(SizeMode sizeMode) : this() { this.Value = 1; this.SizeMode = sizeMode; }