本文整理汇总了C#中GraphicsMode类的典型用法代码示例。如果您正苦于以下问题:C# GraphicsMode类的具体用法?C# GraphicsMode怎么用?C# GraphicsMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsMode类属于命名空间,在下文中一共展示了GraphicsMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AglContext
public AglContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext)
{
Debug.Print("Context Type: {0}", shareContext);
Debug.Print("Window info: {0}", window);
this.graphics_mode = mode;
this.carbonWindow = (CarbonWindowInfo)window;
if (shareContext is AglContext)
shareContextRef = ((AglContext)shareContext).Handle.Handle;
if (shareContext is GraphicsContext)
{
ContextHandle shareHandle = shareContext != null ?
(shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
shareContextRef = shareHandle.Handle;
}
if (shareContextRef == IntPtr.Zero)
{
Debug.Print("No context sharing will take place.");
}
CreateContext(mode, carbonWindow, shareContextRef, true);
}
示例2: AglContext
public AglContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext,
GetInt xoffset, GetInt yoffset)
{
Debug.Print("Share context: {0}", shareContext);
Debug.Print("Window info: {0}", window);
IntPtr shareContextRef = IntPtr.Zero;
XOffset = xoffset;
YOffset = yoffset;
carbonWindow = window;
if (shareContext is AglContext)
{
shareContextRef = ((AglContext)shareContext).Handle.Handle;
}
else if (shareContext is GraphicsContext)
{
ContextHandle shareHandle = shareContext != null ? (shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
shareContextRef = shareHandle.Handle;
}
if (shareContextRef == IntPtr.Zero)
{
Debug.Print("No context sharing will take place.");
}
CreateContext(mode, carbonWindow, shareContextRef, true);
}
示例3: SelectGraphicsMode
public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
{
GraphicsMode gfx = new GraphicsMode((IntPtr)1, color, depth, stencil, samples,
accum, buffers, stereo);
System.Diagnostics.Debug.Print("Created dummy graphics mode.");
return gfx;
}
示例4: imageLoader
public static Bitmap imageLoader(GBAROM ROM, int imageOffset, int paletteOffset, int width, int height, bool isImageCompressed, bool isPaletteCompressed, bool transparent, GraphicsMode mode)
{
DataBuffer rawGraphics = new DataBuffer(0x8000);
DataBuffer rawPalette = new DataBuffer(0x100);
if (isImageCompressed)
{
rawGraphics.ReadCompressedData(ROM, imageOffset);
}
else
{
int gfxlength = GBAGraphics.RawGraphicsLength(new Size(width * 8, height * 8), mode);
rawGraphics.ReadData(ROM, imageOffset, gfxlength);
}
if (isPaletteCompressed)
{
rawPalette.ReadCompressedData(ROM, paletteOffset);
}
else
{
rawPalette.ReadData(ROM, paletteOffset, 0x200);
}
byte[] graphics = rawGraphics.ToArray();
int bitsPerPixel = GBAGraphics.BitsPerPixel(mode);
int length = Math.Min(bitsPerPixel * width * height / 8, graphics.Length);
Color[] palette;
if (rawPalette.Length > 0 && paletteOffset != 0)
palette = GBAPalette.ToPalette(rawPalette.ToArray(), 0, rawPalette.Length / 2);
else
{
palette = new Color[16];
for (int i = 0; i < palette.Length; i++)
palette[i] = Color.FromArgb(i * (256 / palette.Length), i * (256 / palette.Length), i * (256 / palette.Length));
}
int empty;
if(transparent)
palette[0] = Color.FromArgb(0, palette[0]);
return GBAGraphics.ToBitmap(graphics, length, 0, palette, width, mode, out empty);
}
示例5: ToBitmap
public static Bitmap ToBitmap(byte* GBAGraphics, int length, Color[] palette, int width, GraphicsMode mode, out int emptyGraphicBlocks)
{
Bitmap result = null;
emptyGraphicBlocks = 0;
switch (mode)
{
case GraphicsMode.Tile8bit:
result = FromTile8bit(GBAGraphics, length, palette, width, out emptyGraphicBlocks);
break;
case GraphicsMode.Tile4bit:
result = FromTile4bit(GBAGraphics, length, palette, width, out emptyGraphicBlocks);
break;
case GraphicsMode.BitmapTrueColour:
result = FromBitmapTrueColour(GBAGraphics, length, palette, width, out emptyGraphicBlocks);
break;
case GraphicsMode.Bitmap8bit:
result = FromBitmapIndexed(GBAGraphics, length, palette, width, out emptyGraphicBlocks);
break;
}
return result;
}
示例6: CreateContext
void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow, IntPtr shareContextRef, bool fullscreen)
{
List<int> aglAttributes = new List<int>();
Debug.Print("AGL pixel format attributes:");
Debug.Indent();
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_RGBA);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_DOUBLEBUFFER);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_RED_SIZE, mode.ColorFormat.Red);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_GREEN_SIZE, mode.ColorFormat.Green);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_BLUE_SIZE, mode.ColorFormat.Blue);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ALPHA_SIZE, mode.ColorFormat.Alpha);
if (mode.Depth > 0)
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_DEPTH_SIZE, mode.Depth);
if (mode.Stencil > 0)
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_STENCIL_SIZE, mode.Stencil);
if (mode.AccumulatorFormat.BitsPerPixel > 0)
{
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_RED_SIZE, mode.AccumulatorFormat.Red);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_GREEN_SIZE, mode.AccumulatorFormat.Green);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_BLUE_SIZE, mode.AccumulatorFormat.Blue);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_ALPHA_SIZE, mode.AccumulatorFormat.Alpha);
}
if (mode.Samples > 1)
{
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_SAMPLE_BUFFERS_ARB, 1);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_SAMPLES_ARB, mode.Samples);
}
if (fullscreen)
{
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_FULLSCREEN);
}
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_NONE);
Debug.Unindent();
Debug.Write("Attribute array: ");
for (int i = 0; i < aglAttributes.Count; i++)
Debug.Write(aglAttributes[i].ToString() + " ");
Debug.WriteLine("");
AGLPixelFormat myAGLPixelFormat;
// Choose a pixel format with the attributes we specified.
if (fullscreen)
{
IntPtr gdevice;
IntPtr cgdevice = GetQuartzDevice(carbonWindow);
if (cgdevice == IntPtr.Zero)
cgdevice = (IntPtr)DisplayDevice.Default.Id;
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(cgdevice, out gdevice, false);
if (status != OSStatus.NoError)
throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
myAGLPixelFormat = Agl.aglChoosePixelFormat(ref gdevice, 1, aglAttributes.ToArray());
Agl.AglError err = Agl.GetError();
if (err == Agl.AglError.BadPixelFormat)
{
Debug.Print("Failed to create full screen pixel format.");
Debug.Print("Trying again to create a non-fullscreen pixel format.");
CreateContext(mode, carbonWindow, shareContextRef, false);
return;
}
}
else
{
myAGLPixelFormat = Agl.aglChoosePixelFormat(IntPtr.Zero, 0, aglAttributes.ToArray());
MyAGLReportError("aglChoosePixelFormat");
}
Debug.Print("Creating AGL context. Sharing with {0}", shareContextRef);
// create the context and share it with the share reference.
Handle = new ContextHandle(Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
MyAGLReportError("aglCreateContext");
// Free the pixel format from memory.
Agl.aglDestroyPixelFormat(myAGLPixelFormat);
MyAGLReportError("aglDestroyPixelFormat");
Debug.Print("IsControl: {0}", carbonWindow.IsControl);
SetDrawable(carbonWindow);
SetBufferRect(carbonWindow);
Update(carbonWindow);
//.........这里部分代码省略.........
示例7: DrawTicks
/// <summary>Draw the slider ticks</summary>
private void DrawTicks(Graphics g, Rectangle bounds)
{
Rectangle trackRect = GetTrackRectangle();
float increment = (float)Increment();
increment = (float)Increment();
int count = (int)(IncrementScale());
float endcap = (Orientation == Orientation.Horizontal ? (float)trackRect.Right - (1 + ButtonSize.Width / 2) : (float)trackRect.Bottom - (1 + ButtonSize.Height / 2));
float offset = 0;
int shadowlen = TickMaxLength - 1;
int spacer = TickMaxLength + TickMinPadding;
RectangleF buttonRect = GetButtonRectangle();
switch (TickType)
{
#region Composite Style
case TickMode.Composite:
{
using (GraphicsMode md = new GraphicsMode(g, SmoothingMode.None))
{
switch (TickStyle)
{
case TickStyle.Both:
{
if (Orientation == Orientation.Horizontal)
{
float top = buttonRect.Top - spacer;
float bottom = buttonRect.Bottom + spacer;
offset = (ButtonSize.Width / 2) + TrackPadding;
float val = offset;
using (Pen pn = new Pen(TickColor, .5f), pn2 = new Pen(TickColor, 1f), pn3 = new Pen(Color.FromArgb(100, Color.DarkGray), 1f))
{
for (int i = 0; i < count + 1; i++)
{
val = (increment * i) + offset;
if (Mod(i, LargeChange))
{
g.DrawLine(pn2, new PointF(val, top), new PointF(val, top + TickMaxLength));
g.DrawLine(pn3, new PointF(val + 1, top + 1), new PointF(val + 1, top + shadowlen));
g.DrawLine(pn2, new PointF(val, bottom), new PointF(val, bottom - TickMaxLength));
g.DrawLine(pn3, new PointF(val + 1, bottom), new PointF(val + 1, bottom - shadowlen));
}
else
{
g.DrawLine(pn, new PointF(val, top), new PointF(val, top + 2));
g.DrawLine(pn, new PointF(val, bottom), new PointF(val, bottom - 2));
}
}
}
}
else
{
float left = buttonRect.Left - spacer;
float right = buttonRect.Right + spacer;
offset = (ButtonSize.Height / 2) + TrackPadding;
float val = offset;
using (Pen pn = new Pen(TickColor, .5f), pn2 = new Pen(TickColor, 1f), pn3 = new Pen(Color.FromArgb(100, Color.DarkGray), 1f))
{
for (int i = 0; i < count + 1; i++)
{
val = (increment * i) + offset;
if (Mod(i, LargeChange))
{
g.DrawLine(pn2, new PointF(left, val), new PointF(left + TickMaxLength, val));
g.DrawLine(pn3, new PointF(left + 1, val + 1), new PointF(left + shadowlen, val + 1));
g.DrawLine(pn2, new PointF(right, val), new PointF(right - TickMaxLength, val));
g.DrawLine(pn3, new PointF(right, val + 1), new PointF(right - shadowlen, val + 1));
}
else
{
g.DrawLine(pn, new PointF(left, val), new PointF(left + 2, val));
g.DrawLine(pn, new PointF(right, val), new PointF(right - 2, val));
}
}
}
}
break;
}
case TickStyle.BottomRight:
{
if (Orientation == Orientation.Horizontal)
{
float bottom = buttonRect.Bottom + spacer;
offset = (ButtonSize.Width / 2) + TrackPadding;
float val = offset;
using (Pen pn = new Pen(TickColor, .5f), pn2 = new Pen(TickColor, 1f), pn3 = new Pen(Color.FromArgb(100, Color.DarkGray), 1f))
{
for (int i = 0; i < count + 1; i++)
{
val = (increment * i) + offset;
if (Mod(i, LargeChange))
{
g.DrawLine(pn2, new PointF(val, bottom), new PointF(val, bottom - TickMaxLength));
g.DrawLine(pn3, new PointF(val + 1, bottom), new PointF(val + 1, bottom - shadowlen));
}
else
{
g.DrawLine(pn, new PointF(val, bottom), new PointF(val, bottom - 2));
//.........这里部分代码省略.........
示例8: CreateContext
void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow, IntPtr shareContextRef, bool fullscreen)
{
Debug.Print("AGL pixel format attributes:");
AGLPixelFormat myAGLPixelFormat;
// Choose a pixel format with the attributes we specified.
IntPtr gdevice;
IntPtr cgdevice = GetQuartzDevice(carbonWindow);
if (cgdevice == IntPtr.Zero)
cgdevice = (IntPtr)DisplayDevice.Default.Id;
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(cgdevice, out gdevice, false);
if (status != OSStatus.NoError)
throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
IGraphicsMode selector = new MacOSGraphicsMode(gdevice);
Mode = selector.SelectGraphicsMode(
mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples,
mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
MyAGLReportError("aglChoosePixelFormat");
Debug.Print("Creating AGL context. Sharing with {0}", shareContextRef);
myAGLPixelFormat = Mode.Index.Value;
// create the context and share it with the share reference.
Handle = new ContextHandle(Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
MyAGLReportError("aglCreateContext");
// Free the pixel format from memory.
Agl.aglDestroyPixelFormat(myAGLPixelFormat);
MyAGLReportError("aglDestroyPixelFormat");
Debug.Print("IsControl: {0}", carbonWindow.IsControl);
SetDrawable(carbonWindow);
SetBufferRect(carbonWindow);
Update(carbonWindow);
MakeCurrent(carbonWindow);
Debug.Print("context: {0}", Handle.Handle);
}
示例9: CreateGLContext
public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window)
{
//return new WinDXContext( mode, (WinWindowInfo)window );
return new WinGLContext(mode, (WinWindowInfo)window);
}
示例10: CreateContext
void CreateContext(GraphicsMode mode, IWindowInfo carbonWindow, IntPtr shareContextRef, bool fullscreen)
{
Debug.Print("AGL pixel format attributes:");
// Choose a pixel format with the attributes we specified.
AGLPixelFormat pixelformat;
AglGraphicsMode selector = new AglGraphicsMode();
Mode = selector.SelectGraphicsMode(
mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples,
mode.AccumulatorFormat, mode.Buffers, mode.Stereo,
out pixelformat);
MyAGLReportError("aglChoosePixelFormat");
Debug.Print("Creating AGL context. Sharing with {0}", shareContextRef);
// create the context and share it with the share reference.
Handle = new ContextHandle(Agl.aglCreateContext(pixelformat, shareContextRef));
MyAGLReportError("aglCreateContext");
// Free the pixel format from memory.
Agl.aglDestroyPixelFormat(pixelformat);
MyAGLReportError("aglDestroyPixelFormat");
SetDrawable(carbonWindow);
SetBufferRect(carbonWindow);
Update(carbonWindow);
MakeCurrent(carbonWindow);
Debug.Print("context: {0}", Handle.Handle);
dummyContext = new GraphicsContext(Handle,
GetAddress,
delegate()
{
return new ContextHandle(Agl.aglGetCurrentContext());
});
}
示例11: CreateNativeWindow
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
{
throw new PlatformNotSupportedException(error_string);
}
示例12: RawGraphicsLength
public static int RawGraphicsLength(Size size, GraphicsMode mode)
{
return size.Width * size.Height * BitsPerPixel(mode) / 8;
}
示例13: GenerateGBAImage
public static byte[][] GenerateGBAImage(Bitmap bitmap, GraphicsMode mode)
{
byte[][] result;
Bitmap quantazised;
BitmapData bmp;
switch (mode)
{
case GraphicsMode.Tile8bit:
result = new byte[3][];
quantazised = Quantazase(bitmap);
result[0] = ToTile8bit(bitmap, quantazised.Palette.Entries);
result[1] = toRawGBAPalette(quantazised.Palette.Entries);
//yes, I'm lazy
result[2] = new byte[result[0].Length * 2];
fixed (byte* temp = &result[2][0])
{
short* pointer = (short*)temp;
int tiles = 0;
for (int i = 0; i < result[0].Length; i++)
{
pointer[i] = (short)tiles++;
}
}
break;
case GraphicsMode.Tile4bit:
result = new byte[3][];
quantazised = Quantazase(bitmap);
result[0] = ToTile4bit(bitmap, quantazised.Palette.Entries);
result[1] = toRawGBAPalette(quantazised.Palette.Entries);
//yes, I'm lazy
result[2] = new byte[result[0].Length * 2];
fixed (byte* temp = &result[2][0])
{
short* pointer = (short*)temp;
int tiles = 0;
for (int i = 0; i < result[0].Length; i++)
{
pointer[i] = (short)tiles++;
}
}
break;
default:
throw new ArgumentException();
}
return result;
}
示例14: BitsPerPixel
public static int BitsPerPixel(GraphicsMode mode)
{
switch (mode)
{
case GraphicsMode.Tile8bit:
return 8;
case GraphicsMode.Tile4bit:
return 4;
case GraphicsMode.BitmapTrueColour:
return 16;
case GraphicsMode.Bitmap8bit:
return 8;
default:
return 0;
}
}
示例15: DrawTrack
/// <summary>Draw slider and background dc</summary>
private void DrawTrack()
{
BitBlt(_cControlDc.Hdc, 0, 0, _cTrackDc.Width, _cTrackDc.Height, _cTrackDc.Hdc, 0, 0, 0xCC0020);
if (TrackStyle == TrackType.Progress)
{
Rectangle trackRect = GetTrackRectangle();
Rectangle buttonRect = GetButtonRectangle();
int length;
trackRect.Inflate(-1, -1);
if (Orientation == Orientation.Horizontal)
{
if (_iValue == _iMinimum)
{
length = 0;
}
else if (_iValue == _iMaximum)
{
if (SmoothScrolling)
{
length = buttonRect.Right - (trackRect.Left + 1);
trackRect.Width = length;
}
else
{
length = buttonRect.Right - (trackRect.Left + 2);
trackRect.Width = length;
}
}
else
{
length = buttonRect.Right - (trackRect.Left + (int)(buttonRect.Width * .5f));
trackRect.Width = length;
}
}
else
{
if (_iValue == _iMinimum)
{
length = 0;
}
else if (_iValue == _iMaximum)
{
if (SmoothScrolling)
{
length = trackRect.Bottom - (buttonRect.Top + 1);
trackRect.Y = buttonRect.Top - 1;
trackRect.Height = length;
}
else
{
length = trackRect.Bottom - (buttonRect.Top + 3);
trackRect.Height = length;
}
}
else
{
length = trackRect.Bottom - (buttonRect.Top + (int)(buttonRect.Height * .5f));
trackRect.Y = buttonRect.Top + (int)(buttonRect.Height * .5f) - 2;
trackRect.Height = length;
}
}
if (length > 1)
{
using (Graphics g = Graphics.FromHdc(_cControlDc.Hdc))
{
using (GraphicsMode mode = new GraphicsMode(g, SmoothingMode.HighQuality))
{
using (GraphicsPath gp = CreateRoundRectanglePath(g, trackRect, 2))
{
using (LinearGradientBrush fillBrush = new LinearGradientBrush(
buttonRect,
Color.FromArgb(120, Color.White),
Color.FromArgb(250, TrackProgressColor),
(Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal))
{
Blend blnd = new Blend();
blnd.Positions = new[] { 0f, .5f, 1f };
blnd.Factors = new[] { .5f, .7f, .3f };
fillBrush.Blend = blnd;
g.FillPath(fillBrush, gp);
}
}
}
}
}
}
}