/** <summary>Creates a new form within the specified document context.</summary> <param name="context">Document where to place this form.</param> <param name="size">Form size.</param> */ public FormXObject( Document context, drawing::SizeF size ) : this(context, new drawing::RectangleF(new drawing::PointF(0, 0), size)) { }
public RenderableText(string pmText, Sdx.Font pmFont, Point pmPosition, float pmWrapSize) { text= pmText; font= pmFont; position= pmPosition; wrapSize= pmWrapSize; }
/** <summary>Creates a new form within the specified document context.</summary> <param name="context">Document where to place this form.</param> <param name="box">Form box.</param> */ public FormXObject( Document context, drawing::RectangleF box ) : base(context) { BaseDataObject.Header[PdfName.Subtype] = PdfName.Form; Box = box; }
/// <summary> /// Initializes the BitmapBuffer from a System.Drawing.Bitmap /// </summary> public BitmapBuffer(sd.Bitmap bitmap, BitmapLoadOptions options) { if (options.AllowWrap && bitmap.PixelFormat == PixelFormat.Format32bppArgb) { Width = bitmap.Width; Height = bitmap.Height; WrappedBitmap = bitmap; } else LoadInternal(null, bitmap, options); }
public void CleanUp(D2D1.RenderTarget target, GDI.Graphics g, Map map) { target.EndDraw(); using (var sc = TakeScreenshotGdi(map.Size)) g.DrawImage(sc, new GDI.Point(0, 0)); target.Dispose(); //Monitor.Exit(_syncRoot); }
/// <summary> /// Get the W3C standard MIME type for this image /// </summary> /// <param name="image">Image to parse</param> /// <returns>Image MIME type or 'image/unknown' if not found</returns> public static string GetMIMEType(SysDrawing.Image image) { // [Citation("200803142256", AcquiredDate = "2008-03-14", Author = "Chris Hynes", Source = "http://chrishynes.net/blog/archive/2008/01/17/Get-the-MIME-type-of-a-System.Drawing-Image.aspx", SourceDate = "2008-01-17")] foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders()) { if (codec.FormatID == image.RawFormat.Guid) return codec.MimeType; } return Mime.Map[""].MediaType; }
/// <summary> /// Constructs a system tray icon /// </summary> /// <param name="mainForm"></param> /// <param name="icon"></param> public SysTrayIcon(MainForm mainForm, Drawing.Icon icon) { this.mainForm = mainForm; this.notify = new WinForms.NotifyIcon(); this.notify.Text = "NBM"; this.notify.Icon = icon; this.notify.Click += new EventHandler(OnSysTrayClick); this.notify.ContextMenu = new SysTrayContextMenu(mainForm); this.notify.Visible = true; }
private static void Aiguille2(Graphics g, double pc, D.Brush b, double r, float pw, double x0, double y0) { double x1, y1, x2, y2; double a = GetAFromPc(pc); GetXY2(a, r, x0, y0, out x1, out y1); GetXY2(a+Math.PI, r/5.0, x0, y0, out x2, out y2); g.DrawLine(new D.Pen(b, pw), (float)x1, (float)y1, (float)x2, (float)y2); }
public static Texture2D BitmapToTexture(GraphicsDevice device, Gdi.Bitmap bitmap) { MemoryStream ms = new MemoryStream(); bitmap.Save(ms, ImageFormat.Png); // Save the bitmap to memory bitmap.Dispose(); // Dispose the bitmap object Texture2D tex = Texture2D.FromStream(device, ms); // Load the texture from the bitmap in memory ms.Close(); // Close the memorystream ms.Dispose(); // Dispose the memorystream return tex; // return the texture }
public Gdi.RectangleF ToScaledRectangleF(Gdi.Size screenBounds, Vector3D position, double radius) { var size = (float)(2 * radius); return new Gdi.RectangleF { X = (float)(position.X * screenBounds.Width - radius), Y = (float)(position.Y * screenBounds.Height - radius), Width = size, Height = size }; }
private Dictionary<JointType, Vector3D> CalculateBoxJoints(Gdi.RectangleF skeletonBox) { return base.SkeletonComponent.CurrentSkeleton.Select(kvp => Tuple.Create( kvp.Key, new Vector3D( kvp.Value.LocationScreenPercent.X * skeletonBox.Width + skeletonBox.X, (1 - kvp.Value.LocationScreenPercent.Y) * skeletonBox.Height + skeletonBox.Y, //y is flipped 0))) .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2); }
public static NSImage Resize(this NSImage image, sd.Size newsize, ImageInterpolation interpolation = ImageInterpolation.Default) { var newimage = new NSImage(newsize); var newrep = new NSBitmapImageRep(IntPtr.Zero, newsize.Width, newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * newsize.Width, 32); newimage.AddRepresentation(newrep); var graphics = NSGraphicsContext.FromBitmap(newrep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphics; graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG(); image.DrawInRect(new sd.RectangleF(sd.PointF.Empty, newimage.Size), new sd.RectangleF(sd.PointF.Empty, image.Size), NSCompositingOperation.SourceOver, 1f); NSGraphicsContext.GlobalRestoreGraphicsState(); return newimage; }
public byte[] EncodeGdi(SD.Bitmap image, float bitrate = WsqCodec.Constants.DefaultBitrate, bool autoConvertToGrayscale = true) { if (image == null) throw new ArgumentNullException("image"); RawImageData data = null; if (autoConvertToGrayscale) { using (var source = Conversions.To8bppBitmap(image)) data = Conversions.GdiImageToImageInfo(source); } else data = Conversions.GdiImageToImageInfo(image); return WsqCodec.Encode(data, bitrate, Comment); }
/// <summary> /// Function to start showing video /// </summary> /// <param name="videoHandle">Video handle</param> /// <param name="videoRegion">Region where to show video</param> /// <param name="videoHorizontalResolution">Video horizontal resolution</param> /// <param name="videoVerticalResolution">Video vertical resolution</param> public void StartVideo(IntPtr videoHandle, SD.Rectangle videoRegion, int videoHorizontalResolution, int videoVerticalResolution) { //// Creates instance of Web cam class of DirectShow this.webCam = new Webcam(videoHandle); var selectedCamera = this.SelectCamera(); if (selectedCamera >= 0) { var deviceName = this.webCam.StartVideo(videoHandle, videoRegion, videoHorizontalResolution, videoVerticalResolution, selectedCamera); CameraStatus.Status = string.IsNullOrEmpty(deviceName) ? CameraAvailability.Busy : CameraAvailability.Available; } else { CameraStatus.Status = CameraAvailability.NotAvailable; } }
private static Drawing.Icon DrawIcon(Drawing.Brush fillBrush, string message, int dimension) { Drawing.Icon oIcon = null; Drawing.Bitmap bm = new Drawing.Bitmap(dimension, dimension); Drawing.Graphics g = Drawing.Graphics.FromImage((Drawing.Image)bm); g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias; Drawing.Font oFont = new Drawing.Font("Arial", 30, Drawing.FontStyle.Bold, Drawing.GraphicsUnit.Pixel); g.FillRectangle(fillBrush, new Drawing.Rectangle(0, 0, bm.Width, bm.Height)); g.DrawString(message, oFont, new Drawing.SolidBrush(Drawing.Color.Black), 2, 0); oIcon = Drawing.Icon.FromHandle(bm.GetHicon()); oFont.Dispose(); g.Dispose(); bm.Dispose(); return oIcon; }
public Texture(Sdx.Bitmap bmp) { // Variables Sdx.Imaging.BitmapData bmpdata= bmp.LockBits(new Sdx.Rectangle(0, 0, bmp.Width, bmp.Height), Sdx.Imaging.ImageLockMode.ReadOnly, Sdx.Imaging.PixelFormat.Format32bppArgb); int tid= GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, tid); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp.Width, bmp.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bmpdata.Scan0); bmp.UnlockBits(bmpdata); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int) TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int) TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int) TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int) TextureWrapMode.Repeat); ID= tid; bitmap= bmp; }
/// <summary> /// Function to calculate new height of the image container as per dimension of the picture /// </summary> /// <param name="pictureSize">Captured picture size</param> /// <param name="imageContainer">Image container whose size is to be changed</param> public static void AdjustPictureBoxSize(SD.Size pictureSize, Image imageContainer) { if (imageContainer != null) { if (pictureSize.Width > imageContainer.Width) { // Calculates and set new height of image container as per photoSize imageContainer.Height = (imageContainer.Width * pictureSize.Height) / pictureSize.Width; imageContainer.Stretch = Stretch.Uniform; } else { imageContainer.Width = imageContainer.Width; imageContainer.Height = pictureSize.Height; imageContainer.Stretch = Stretch.None; } } }
public Screen( Page page, drawing::RectangleF box, String text, String mediaPath, String mimeType ) : this(page, box, text, new MediaRendition( new MediaClipData( FileSpecification.Get( EmbeddedFile.Get(page.Document, mediaPath), System.IO.Path.GetFileName(mediaPath) ), mimeType ) )) { }
public static BitmapSource ToBitmapSource(SD.Bitmap source) { var hBitmap = source.GetHbitmap(); try { return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } catch (Win32Exception) { return null; } finally { DeleteObject(hBitmap); } }
public override void Render(GDI.Graphics g, Map map) { if (map.Center == null) throw (new ApplicationException("Cannot render map. View center not specified")); g.SmoothingMode = SmoothingMode; var envelope = ToSource(map.Envelope); //View to render if (DataSource == null) throw (new ApplicationException("DataSource property not set on layer '" + LayerName + "'")); // Get the transform var transform = new Matrix3x2(g.Transform.Elements); // Save state of the graphics object var gs = g.Save(); // Create and prepare the render target var rt = RenderTargetFactory.Create(_d2d1Factory, g, map); // Set anti-alias mode and transform rt.AntialiasMode = AntialiasMode; rt.Transform = transform; if (Theme != null) RenderInternal(_d2d1Factory, rt, map, envelope, Theme); else RenderInternal(_d2d1Factory, rt, map, envelope); // Clean up the render target RenderTargetFactory.CleanUp(rt, g, map); // Restore the graphics object g.Restore(gs); // Invoke LayerRendered event OnLayerRendered(g); }
public D2D1.RenderTarget Create(D2D1.Factory factory, GDI.Graphics g, Map map) { //Monitor.Enter(_syncRoot); // Dispose the _renderTexture if it is instantiated and not of the required size CheckTexture(ref _renderTexture, map.Size); // Create a new render texture if one is needed if (_renderTexture == null) { _renderTexture = CreateRenderTargetTexture(_d3d11Device, map.Size.Width, map.Size.Height); } // Get the surface var surface = _renderTexture.QueryInterface<DXGI.Surface>(); var res = new D2D1.RenderTarget(factory, surface, new D2D1.RenderTargetProperties( D2D1.RenderTargetType.Hardware, new D2D1.PixelFormat(DXGI.Format.B8G8R8A8_UNorm, D2D1.AlphaMode.Premultiplied), g.DpiX, g.DpiY, D2D1.RenderTargetUsage.None, D2D1.FeatureLevel.Level_DEFAULT)); res.BeginDraw(); return res; }
public void SetModulateColor(sd.Color color) { //white is really no color at all if (color.ToArgb() == sd.Color.White.ToArgb()) { CurrentImageAttributes.ClearColorMatrix(ColorAdjustType.Bitmap); return; } float r = color.R / 255.0f; float g = color.G / 255.0f; float b = color.B / 255.0f; float a = color.A / 255.0f; float[][] colorMatrixElements = { new float[] {r, 0, 0, 0, 0}, new float[] {0, g, 0, 0, 0}, new float[] {0, 0, b, 0, 0}, new float[] {0, 0, 0, a, 0}, new float[] {0, 0, 0, 0, 1}}; ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements); CurrentImageAttributes.SetColorMatrix(colorMatrix,ColorMatrixFlag.Default, ColorAdjustType.Bitmap); }
private void FitObjectHeight(LayoutObject obj, Layout.Rectangle bounds) { int newHeight = bounds.Height; int newWidth = (int)((double)newHeight / obj.Aspect); obj.ActualWidth = newWidth; obj.ActualHeight = newHeight; int x = (int)(((double)bounds.Width / 2) - ((double)newWidth / 2)); obj.X = x; obj.Y = 0; }
public byte[] EncodeQualityGdi(SD.Bitmap image, int quality, bool autoConvertToGrayscale = true) { return EncodeCompressionRatioGdi(image, WsqCodec.QualityToCompressionRatio(quality), autoConvertToGrayscale); }
public byte[] EncodeCompressionRatioGdi(SD.Bitmap image, float compressionRatio, bool autoConvertToGrayscale = true) { return EncodeGdi(image, WsqCodec.CompressionRatioToBitrate(compressionRatio), autoConvertToGrayscale); }
static public Area Measure(string sText, SysDrw.Font cFont, bool bHeight) { try // ВНИМАНИЕ! MeasureString не учитывает последние пробелы!! // И не учитывает шрифт италик (наклонный)!!!! { SysDrw.Graphics cGraphics = SysDrw.Graphics.FromImage(new SysDrw.Bitmap(1, 1)); SysDrw.SizeF cTextSize = cGraphics.MeasureString(sText, cFont, 10000, SysDrw.StringFormat.GenericTypographic); if (bHeight) return new Area(0, 0, (ushort)(cTextSize.Width * 0.75F + 1), (ushort)(cTextSize.Height * 0.75F + 1)); else return new Area(0, 0, (ushort)(cTextSize.Width * 0.75F + 1), 0); } catch (Exception ex) { (new Logger()).WriteError(ex); return new Area(0, 0, 0, 0); } }
private ushort MeasureWidth(string sText, SysDrw.Font cFont) { return Measure(sText, cFont, false).nWidth; }
public static void SetFrameSize(this UIView view, sd.SizeF size) { var frame = view.Frame; frame.Size = size; view.Frame = frame; }
/// <summary> /// Displays the image /// </summary> private void DisplayImage(string thumbnail, Store.Image image, out Img.Image drawnImage, out System.Web.UI.WebControls.Image displayImage) { drawnImage = Img.Image.FromFile(Server.MapPath(thumbnail)); displayImage = new System.Web.UI.WebControls.Image(); displayImage.ImageUrl = thumbnail; displayImage.Attributes.Add("BigImageUrl", Page.ResolveUrl(image.ImageFile)); displayImage.Attributes.Add("rel", productId.ToString()); displayImage.Attributes.Add("title", image.Caption); imageList.Add(displayImage); }
private void FitObjectWidth(LayoutObject obj, Layout.Rectangle bounds) { int newWidth = bounds.Width; int newHeight = (int)((double)newWidth * obj.Aspect); obj.ActualWidth = newWidth; obj.ActualHeight = newHeight; int y = (int)(((double)bounds.Height / 2) - ((double)newHeight / 2)); obj.X = 0; obj.Y = y; }