i used setdevicegammaramp api in console c# application , worked well. when same used in universal windows app error "cs1620 argument 2 must passed 'ref' keyword" appeared.
my requirement change gamma value using slider control.
code area:
using system; using system.collections.generic; using system.io; using system.linq; using system.runtime.interopservices.windowsruntime; using windows.foundation; using windows.foundation.collections; using windows.ui.xaml; using windows.ui.xaml.controls; using windows.ui.xaml.controls.primitives; using windows.ui.xaml.data; using windows.ui.xaml.input; using windows.ui.xaml.media; using windows.ui.xaml.navigation; using system.runtime.interopservices; // blank page item template documented @ http://go.microsoft.com/fwlink/?linkid=402352&clcid=0x409 namespace brightness { /// <summary> /// empty page can used on own or navigated within frame. /// </summary> public sealed partial class mainpage : page { [dllimport("user32.dll")] public static extern intptr getdc(intptr hwnd); [dllimport("gdi32.dll")] public static extern bool setdevicegammaramp(intptr hdc, ref ramp lpramp); [structlayout(layoutkind.sequential, charset = charset.ansi)] public struct ramp { [marshalas(unmanagedtype.byvalarray, sizeconst = 256)] public uint16[] red; [marshalas(unmanagedtype.byvalarray, sizeconst = 256)] public uint16[] green; [marshalas(unmanagedtype.byvalarray, sizeconst = 256)] public uint16[] blue; } public mainpage() { this.initializecomponent(); } public static void setgamma(int gamma) { if (gamma <= 256 && gamma >= 1) { ramp ramp = new ramp(); ramp.red = new ushort[256]; ramp.green = new ushort[256]; ramp.blue = new ushort[256]; (int = 1; < 256; i++) { int iarrayvalue = * (gamma + 128); if (iarrayvalue > 65535) { iarrayvalue = 65535; } ramp.red[i] = ramp.blue[i] = ramp.green[i] = (ushort)iarrayvalue; } setdevicegammaramp(getdc(intptr.zero), ref ramp); } } private void slider_valuechanged(object sender, rangebasevaluechangedeventargs e) { slider slider = sender slider; if (slider != null) { int p = (int)slider.value; setgamma(p); } } } } enter code here
error: cs1620: argument 2 must passed 'ref' keyword
i new c# , universal windows app. please help.
you can't change gamma value using slider since slide down automatically when try change it. application can't refer value on sliding condition. try fix sliding issue first. can change gamma value using injection method.
Comments
Post a Comment