本文整理汇总了C#中RenderMode类的典型用法代码示例。如果您正苦于以下问题:C# RenderMode类的具体用法?C# RenderMode怎么用?C# RenderMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenderMode类属于命名空间,在下文中一共展示了RenderMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
{
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0)
{
// nothing to do
return;
}
GraphicsState state = graphics.Save();
if (Invert)
{
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
ColorMatrix grayscaleMatrix = new ColorMatrix(new[] {
new[] {.3f, .3f, .3f, 0, 0},
new[] {.59f, .59f, .59f, 0, 0},
new[] {.11f, .11f, .11f, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {0, 0, 0, 0, 1}
});
using (ImageAttributes ia = new ImageAttributes())
{
ia.SetColorMatrix(grayscaleMatrix);
graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia);
}
graphics.Restore(state);
}
示例2: Apply
/// <summary>
/// Implements the Apply code for the Brightness Filet
/// </summary>
/// <param name="graphics"></param>
/// <param name="applyBitmap"></param>
/// <param name="rect"></param>
/// <param name="renderMode"></param>
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0) {
// nothing to do
return;
}
GraphicsState state = graphics.Save();
if (Invert) {
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) {
Color highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
for (int y = fastBitmap.Top; y < fastBitmap.Bottom; y++) {
for (int x = fastBitmap.Left; x < fastBitmap.Right; x++) {
Color color = fastBitmap.GetColorAt(x, y);
color = Color.FromArgb(color.A, Math.Min(highlightColor.R, color.R), Math.Min(highlightColor.G, color.G), Math.Min(highlightColor.B, color.B));
fastBitmap.SetColorAt(x, y, color);
}
}
fastBitmap.DrawTo(graphics, applyRect.Location);
}
graphics.Restore(state);
}
示例3: Apply
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
{
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0)
{
// nothing to do
return;
}
int magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR);
GraphicsState state = graphics.Save();
if (Invert)
{
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
graphics.SmoothingMode = SmoothingMode.None;
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
int halfWidth = rect.Width / 2;
int halfHeight = rect.Height / 2;
int newWidth = rect.Width / magnificationFactor;
int newHeight = rect.Height / magnificationFactor;
Rectangle source = new Rectangle(rect.X + halfWidth - (newWidth / 2), rect.Y + halfHeight - (newHeight / 2), newWidth, newHeight);
graphics.DrawImage(applyBitmap, rect, source, GraphicsUnit.Pixel);
graphics.Restore(state);
}
示例4: InitShader
void IRenderable.Render(OpenGL gl, RenderMode renderMode)
{
if (positionBuffer != null && colorBuffer != null && radiusBuffer != null)
{
if (this.shaderProgram == null)
{
this.shaderProgram = InitShader(gl, renderMode);
}
if (this.vertexArrayObject == null)
{
CreateVertexArrayObject(gl, renderMode);
}
BeforeRendering(gl, renderMode);
if (this.RenderGrid && this.vertexArrayObject != null)
{
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);
gl.BindVertexArray(this.vertexArrayObject[0]);
gl.DrawArrays(OpenGL.GL_POINTS, 0, count);
gl.BindVertexArray(0);
gl.Disable(OpenGL.GL_BLEND);
}
AfterRendering(gl, renderMode);
}
}
示例5: Render
/// <summary>
/// Render to the provided instance of OpenGL.
/// </summary>
/// <param name="gl">The OpenGL instance.</param>
/// <param name="renderMode">The render mode.</param>
public override void Render(OpenGL gl, RenderMode renderMode)
{
// Create the evaluator.
gl.Map1(OpenGL.GL_MAP1_VERTEX_3,// Use and produce 3D points.
0, // Low order value of 'u'.
1, // High order value of 'u'.
3, // Size (bytes) of a control point.
ControlPoints.Width, // Order (i.e degree plus one).
ControlPoints.ToFloatArray()); // The control points.
// Enable the type of evaluator we wish to use.
gl.Enable(OpenGL.GL_MAP1_VERTEX_3);
// Beging drawing a line strip.
gl.Begin(OpenGL.GL_LINE_STRIP);
// Now draw it.
for (int i = 0; i <= segments; i++)
gl.EvalCoord1((float)i / segments);
gl.End();
// Draw the control points.
ControlPoints.Draw(gl, DrawControlPoints, DrawControlGrid);
}
示例6: Init
public void Init(RenderMode renderMode)
{
if (renderMode == RenderMode.Render2D)
{
GL.MatrixMode(MatrixMode.Projection);
var aspectRatio = (float)form.ClientSize.Width / form.ClientSize.Height;
GL.LoadIdentity();
GL.Scale(1, aspectRatio, 1);
GL.MatrixMode(MatrixMode.Modelview);
}
else
{
GL.Enable(EnableCap.DepthTest);
GL.ShadeModel(ShadingModel.Smooth);
GL.Enable(EnableCap.Lighting);
GL.Light(LightName.Light0, LightParameter.Ambient, new[] { .2f, .2f, .2f, 1.0f });
GL.Light(LightName.Light0, LightParameter.Diffuse, new[] { 1, 1, 1, 1.0f });
GL.Light(LightName.Light0, LightParameter.Position,
new[] { Common.LightPosition.x, Common.LightPosition.y, Common.LightPosition.z });
GL.Enable(EnableCap.Light0);
GL.MatrixMode(MatrixMode.Projection);
Common.ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(Common.FieldOfView,
form.ClientSize.Width / (float)form.ClientSize.Height, Common.NearPlane, Common.FarPlane);
GL.LoadMatrix(ref Common.ProjectionMatrix);
GL.MatrixMode(MatrixMode.Modelview);
Common.ViewMatrix = Matrix4.LookAt(Common.CameraPosition.x, Common.CameraPosition.y,
Common.CameraPosition.z, 0, 0, 4, 0, 0, 1);
GL.LoadMatrix(ref Common.ViewMatrix);
}
}
示例7: GetCanvas
public static Canvas GetCanvas(RenderMode renderMode) {
Canvas canvas = null;
Canvas[] sceneCanvases = GameObject.FindObjectsOfType<Canvas>();
for (int i = 0; i < sceneCanvases.Length; i++) {
if (sceneCanvases[i].renderMode == renderMode) {
canvas = sceneCanvases[i];
break;
}
}
if (canvas == null) {
GameObject canvasGO = new GameObject("Canvas");
canvasGO.layer = LayerMask.NameToLayer("UI");
canvasGO.AddComponent<GraphicRaycaster>();
canvas = canvasGO.GetComponent<Canvas>();
canvas.renderMode = renderMode;
if (GameObject.FindObjectOfType<EventSystem>() == null) {
GameObject eventSystemGO = new GameObject("EventSystem");
eventSystemGO.AddComponent<EventSystem>();
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IPHONE)
eventSystemGO.AddComponent<TouchInputModule>();
#else
eventSystemGO.AddComponent<StandaloneInputModule>();
#endif
}
}
return canvas;
}
示例8: ActivityButton
public ActivityButton()
{
this.Image = new Uri("pack://application:,,,/Images/activity.PNG");
this.Text = "Default";
this.RenderMode = RenderMode.ImageAndText;
this.VerticalAlignment = System.Windows.VerticalAlignment.Center;
}
示例9: Draw
public override void Draw(Graphics graphics, RenderMode rm) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
if (lineVisible) {
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
//draw shadow first
if (shadow) {
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness)) {
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + currentStep, Top + currentStep, Width, Height);
graphics.DrawRectangle(shadowPen, shadowRect);
currentStep++;
alpha = alpha - (basealpha / steps);
}
}
}
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
if (lineThickness > 0) {
using (Pen pen = new Pen(lineColor, lineThickness)) {
graphics.DrawRectangle(pen, rect);
}
}
}
}
示例10: Generate
private static void Generate(string xamlFile, string outputFile, RenderMode renderMode, string desiredNamespace, string defaultAssembly)
{
string xaml = string.Empty;
using (TextReader tr = File.OpenText(xamlFile))
{
xaml = tr.ReadToEnd();
}
if (!string.IsNullOrEmpty(defaultAssembly))
xaml = Regex.Replace(xaml,
@"xmlns(:\w+)?=\""clr-namespace:([.\w]+)(;assembly=)?\""",
[email protected]"xmlns$1=""clr-namespace:$2;assembly=" + defaultAssembly + '"');
UserInterfaceGenerator generator = new UserInterfaceGenerator();
string generatedCode = string.Empty;
try
{
generatedCode = generator.GenerateCode(xamlFile, xaml, renderMode, desiredNamespace);
}
catch (Exception ex)
{
generatedCode = "#error " + ex.Message;
throw;
}
finally
{
using (StreamWriter outfile = new StreamWriter(outputFile))
{
outfile.Write(generatedCode);
}
}
}
示例11: Draw
public override void Draw(Graphics g, RenderMode rm)
{
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
g.FillRectangle(GetBrush(rect), rect);
Pen pen = new Pen(foreColor) { Width = thickness };
g.DrawRectangle(pen, rect);
}
示例12: Tile
public Tile(Image image, TileCoordinate tile, RenderMode mode)
{
this.tile = tile;
if(image != null)
{
this.mode = mode;
switch(mode)
{
case RenderMode.GDI:
{
using(Bitmap bitmap = new Bitmap(image))
{
this.ptrHbitmap = bitmap.GetHbitmap();
}
}
break;
case RenderMode.GDI_PLUS:
{
this.image = image;
}
break;
}
}
}
示例13: Apply
public unsafe override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
{
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
double previewQuality = GetFieldValueAsDouble(FieldType.PREVIEW_QUALITY);
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0)
{
return;
}
GraphicsState state = graphics.Save();
if (Invert)
{
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
if (GDIplus.IsBlurPossible(blurRadius))
{
GDIplus.DrawWithBlur(graphics, applyBitmap, applyRect, null, null, blurRadius, false);
}
else
{
using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect))
{
ImageHelper.ApplyBoxBlur(fastBitmap, blurRadius);
fastBitmap.DrawTo(graphics, applyRect);
}
}
graphics.Restore(state);
return;
}
示例14: DrawEllipse
/// <summary>
/// This allows another container to draw an ellipse
/// </summary>
/// <param name="caller"></param>
/// <param name="graphics"></param>
/// <param name="renderMode"></param>
public static void DrawEllipse(Rectangle rect, Graphics graphics, RenderMode renderMode, int lineThickness, Color lineColor, Color fillColor, bool shadow) {
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
// draw shadow before anything else
if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowPen.Width = lineVisible ? lineThickness : 1;
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(rect.Left + currentStep, rect.Top + currentStep, rect.Width, rect.Height);
graphics.DrawEllipse(shadowPen, shadowRect);
currentStep++;
alpha = alpha - basealpha / steps;
}
}
}
//draw the original shape
if (Colors.IsVisible(fillColor)) {
using (Brush brush = new SolidBrush(fillColor)) {
graphics.FillEllipse(brush, rect);
}
}
if (lineVisible) {
using (Pen pen = new Pen(lineColor, lineThickness)) {
graphics.DrawEllipse(pen, rect);
}
}
}
示例15: Draw
public override void Draw(Graphics g, RenderMode rm)
{
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
if (Selected && rm.Equals(RenderMode.EDIT)) DrawSelectionBorder(g, rect);
Brush fontBrush = new SolidBrush(foreColor);
g.DrawString(childLabel.Text, childLabel.Font, fontBrush, rect);
}