private void LoadImage() { try { if (!File.Exists(Path.Combine(Application.ResourceUrl, mUrl))) { Console.Write("Image file not found:"); Console.Write(Path.Combine(Application.ResourceUrl, mUrl)); return; } var data = File.ReadAllBytes(mUrl); var height = XpBitConverter.ToInt32(data, 0); var width = XpBitConverter.ToInt32(data, 4); var size = data.Length - 8; var raw = Marshal.AllocHGlobal(size); Marshal.Copy(data, 8, raw, size); //mCache = VG.vgCreateImage(PixelFormat, Width, Height, VGImageQuality.VG_IMAGE_QUALITY_BETTER); //VG.vgImageSubData(mCache, raw, 4 * Width, PixelFormat, 0, 0, Width, Height); VG.vgWritePixels(raw, 4 * width, VGImageFormat.VG_sBGRA_8888, 0, 0, width, height); //VG.vgWritePixels(raw, 4*width, PixelFormat, 0, 0, width, height); Marshal.FreeHGlobal(raw); } catch (Exception ex) { Debug.Print(ex.ToString()); } }
public bool Load(string url) { if (!File.Exists(Path.Combine(Application.ResourceUrl, url))) { Console.Write("Image file not found:"); Console.Write(Path.Combine(Application.ResourceUrl, url)); return(false); } if (mUrl == Path.Combine(Application.ResourceUrl, url)) { return(true); } mUrl = Path.Combine(Application.ResourceUrl, url); var data = new byte[8]; File.OpenRead(mUrl).Read(data, 0, 8); var height = XpBitConverter.ToInt32(data, 0); var width = XpBitConverter.ToInt32(data, 4); Resize(width, height); return(true); }
static public InputEvent ParseEvent(byte[] aData) { if (aData.Length != 16) { return(null); } return(new InputEvent { time = { seconds = XpBitConverter.ToUint32(aData, 0), microseconds = XpBitConverter.ToUint32(aData, 4) }, type = (EventTypes)XpBitConverter.ToUint16(aData, 8), code = (CodeTypes)XpBitConverter.ToUint16(aData, 10), value = XpBitConverter.ToInt32(aData, 12) }); }