首页 \ 问答 \ 安卓系统的手机好不好用呢?

安卓系统的手机好不好用呢?

安卓系统的手机好不好用?
更新时间:2023-11-01 14:11

最满意答案

您可以尝试使用CombinedGeometry组合2个几何(每次)。 它具有GeometryCombineMode允许您指定一些逻辑组合。 在这种情况下,您需要的是GeometryCombineMode.Xor 。 将切除 Rect和Ellipse(cirlce)的交点。 以下是演示它的简单代码:

DrawingVisual dv = new DrawingVisual();
using (var dc = dv.RenderOpen()) {                    
  var rect = new Rect(0, 0, 300, 200);        
  var cb = new CombinedGeometry(GeometryCombineMode.Xor, 
                                new RectangleGeometry(rect),
                               new EllipseGeometry(new Point(150, 100), 50, 50));
  dc.DrawGeometry(Brushes.Blue, null, cb);                    
}

我希望你知道如何渲染DrawingVisual 。 您可以使用一些RenderTargetBitmap将其捕获到某种BitmapSource中,然后您可以通过多种方式显示此位图。

这是截图:

在此处输入图像描述

黑色区域表示颜色是透明的。

如果你想剪出一些复杂的图像(如绘制的文字或图像)。 您可以将CombinedGeometry转换为某种OpacityMaskBrush类型)。 我们可以把它变成DrawingBrush ,这个画笔可以用作OpacityMask ,可以传递给DrawingContext.PushOpacityMask方法:

DrawingVisual dv = new DrawingVisual();                
using (var dc = dv.RenderOpen()) {                    
  var rect = new Rect(0, 0, 300, 200);
  var cb = new CombinedGeometry(GeometryCombineMode.Xor, 
                                new RectangleGeometry(rect),
                               new EllipseGeometry(new Point(150, 100), 50, 50));
  var mask = new DrawingBrush(new GeometryDrawing(Brushes.Blue, null, cb));      
  dc.PushOpacityMask(mask);
  dc.DrawImage(someImage, rect);
  dc.DrawText(new FormattedText("Windows Presentation Foundation", 
                                 System.Globalization.CultureInfo.CurrentCulture, 
                                 System.Windows.FlowDirection.LeftToRight,
                                 new Typeface("Lucida Bright"), 30, Brushes.Red){ 
                                   MaxTextWidth = rect.Width, 
                                   MaxTextHeight = rect.Height, 
                                   TextAlignment = TextAlignment.Center
                                 }, new Point());
}

在此处输入图像描述

请注意, rect应该具有整个图形的大小。 然后定位和其他绘制的东西将是你想要的精确。

最后, DrawingVisual还有一个名为Clip的有用属性,它是一个Geometry 。 因此,您可以准备一些CombinedGeometry并将其分配给DrawingVisual.Clip属性。

假设您已经拥有了DrawingVisual (包含一些绘制的内容,包括文本,图像......)。 以下代码将通过它打孔

//prepare the geometry, which can be considered as the puncher.
var rect = new Rect(0, 0, 300, 200);
var cb = new CombinedGeometry(GeometryCombineMode.Xor, 
                              new RectangleGeometry(rect),
                             new EllipseGeometry(new Point(150, 100), 50, 50));
//punch the DrawingVisual
yourDrawingVisual.Clip = cb;

You can try using CombinedGeometry to combine 2 geometries (each time). It has GeometryCombineMode allowing you to specify some logic combination. In this case what you need is GeometryCombineMode.Xor. The intersection of the Rect and the Ellipse (cirlce) will be cut out. Here is the simple code demonstrating it:

DrawingVisual dv = new DrawingVisual();
using (var dc = dv.RenderOpen()) {                    
  var rect = new Rect(0, 0, 300, 200);        
  var cb = new CombinedGeometry(GeometryCombineMode.Xor, 
                                new RectangleGeometry(rect),
                               new EllipseGeometry(new Point(150, 100), 50, 50));
  dc.DrawGeometry(Brushes.Blue, null, cb);                    
}

I hope you know how to render the DrawingVisual. You can use some RenderTargetBitmap to capture it into some kind of BitmapSource and then you have many ways to show this bitmap.

Here is the screenshot:

enter image description here

The Black region means the color is transparent.

In case you want to cut out some complex image (such as drawn text or image). You can turn the CombinedGeometry into some kind of OpacityMask (type of Brush). We can turn it into a DrawingBrush and this brush can be used as OpacityMask which can be passed into DrawingContext.PushOpacityMask method:

DrawingVisual dv = new DrawingVisual();                
using (var dc = dv.RenderOpen()) {                    
  var rect = new Rect(0, 0, 300, 200);
  var cb = new CombinedGeometry(GeometryCombineMode.Xor, 
                                new RectangleGeometry(rect),
                               new EllipseGeometry(new Point(150, 100), 50, 50));
  var mask = new DrawingBrush(new GeometryDrawing(Brushes.Blue, null, cb));      
  dc.PushOpacityMask(mask);
  dc.DrawImage(someImage, rect);
  dc.DrawText(new FormattedText("Windows Presentation Foundation", 
                                 System.Globalization.CultureInfo.CurrentCulture, 
                                 System.Windows.FlowDirection.LeftToRight,
                                 new Typeface("Lucida Bright"), 30, Brushes.Red){ 
                                   MaxTextWidth = rect.Width, 
                                   MaxTextHeight = rect.Height, 
                                   TextAlignment = TextAlignment.Center
                                 }, new Point());
}

enter image description here

Note that the rect should have the size of your whole drawing. Then positioning the hole and other drawn stuff will be exact as what you want.

Finally the DrawingVisual also has a useful property called Clip which is a Geometry. So you can prepare some CombinedGeometry and assign it to DrawingVisual.Clip property.

Suppose you already have your DrawingVisual (with some drawn stuff including text, images, ...). The following code will punch a hole through it:

//prepare the geometry, which can be considered as the puncher.
var rect = new Rect(0, 0, 300, 200);
var cb = new CombinedGeometry(GeometryCombineMode.Xor, 
                              new RectangleGeometry(rect),
                             new EllipseGeometry(new Point(150, 100), 50, 50));
//punch the DrawingVisual
yourDrawingVisual.Clip = cb;

相关问答

更多
  • 您可以尝试使用CombinedGeometry组合2个几何(每次)。 它具有GeometryCombineMode允许您指定一些逻辑组合。 在这种情况下,您需要的是GeometryCombineMode.Xor 。 将切除 Rect和Ellipse(cirlce)的交点。 以下是演示它的简单代码: DrawingVisual dv = new DrawingVisual(); using (var dc = dv.RenderOpen()) { var rect ...
  • 基于一些经验和基于各种文档的经验,我相信UIGraphicsPushContext()的文档是不正确的。 我相信UIGraphicsPushContext()实际上是线程安全的。 QA1637说明了这一点:“从iOS 4.0开始,在UIKit中绘制图形上下文是线程安全的,包括访问和操作当前图形堆栈 ,绘制图像和字符串以及使用颜色和辅助线程的字体对象“。 (强调我的) 我承认,假设线程安全与文档相矛盾始终是一个冒险的主张。 但我相信这是一个文档错误。 我打开了rdar:// 11161530来跟踪它。 请欺骗 ...
  • 那么这是一个很大的问题。 一个潜在的主要原因是验证你确切地绘制了你所需要的东西(而不是整个图像),并且将不变的位图从那些在多个层次上主动变异的区域/区域划分出来。 Well, this is a big question. One potential lead would be to verify that you draw exactly what you need (not the whole image all the time), and to divide the invariant bitmap ...
  • 刷子无法正常工作,因为当您调用clearImage()时,您将context.fillStyle更改为white,还有context.moveTo(e.offsetX, e.offsetY); 这是不必要的。 看看那个重现https://jsfiddle.net/yr1ezp4x/2/ 那里你会有更多的工作。 在鼠标事件触发的内部函数中,您必须检查鼠标是否在画布上。 Brush doesn't work properly cause when you call clearImage() you are ch ...
  • 你的方法是正确的。 你只是错过了一个小细节。 PDF和postscript文件通常是打印的。 打印文档需要一个边距(打印机需要抓住纸张的边缘)。 (current-ps-setup)用于纸张尺寸,边距大小和缩放。 将缩放比例设置为1并将边距大小设置为0将为您提供预期的结果。 #lang racket (require racket/draw) ;;; Begin our drawing (define w 200) (define h 200) (define setup (new ps-setup%) ...
  • 单击按钮 b1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub dv.clear(); // call clear method using in your custom view } }); ...
  • 无论好坏,我都使用图层: - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); if (first) { // Wait for the first call to get a valid context first = NO; // Then create a CGContextRef (offlineContext ...
  • 我假设drawingPath是一个CGPath ...你清除那个CGPath? 这可能是你的问题的原因 在清除路径的行动中,做: CGPathRelease(drawingPath); drawingPath = CGPathCreateMutable(); [self setNeedsDisplay]; 并做你通常做的正常绘图。 如果路径为空,则不会绘制任何内容 im assuming drawingPath is a CGPath ... are you clearing that CGPath? t ...
  • iOS的“ 绘图和打印指南 ”中的“坐标系统和iOS绘图”中对此进行了解释: iOS的每个绘图框架都基于当前图形上下文建立默认坐标系。 在iOS中,有两种主要类型的坐标系: 左上方原点坐标系(ULO),其中绘制操作的原点位于绘图区域的左上角,正值向下和向右延伸。 UIKit和Core Animation框架使用的默认坐标系是基于ULO的。 左下原点坐标系(LLO),其中绘图操作的原点位于绘图区域的左下角,正值向上和向右延伸。 Core Graphics框架使用的默认坐标系是基于LLO的。 正角度(如M_PI ...
  • 你不需要preserveDrawingBuffer: true来调用readPixels 。 您需要的是在退出当前事件之前调用readPixels 。 规范说如果你调用任何影响画布的函数(gl.clear,gl.drawXXX),浏览器将在下一次复合操作后清除画布。 当复合操作发生时,由浏览器决定。 可能是在它处理了几个鼠标事件或键盘事件或点击事件之后。 订单未定义。 定义的是,在当前事件退出之前不会这样做 render read const gl = document.querySelector("ca ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。