/// <summary> /// Updates a bitmap of the device. Use this function if you want to manually manage the pixels sent /// to the device, without using the Pages feature. /// </summary> /// <param name="pixels">An array of pixels constituting the bitmap. See the SDK help for more information.</param> /// <param name="priority">Priority of the update.</param> /// <param name="updateMode">Update mode (synchronous or asynchronous).</param> /// <returns> /// If <paramref name="updateMode"/> is <see cref="LcdUpdateMode.SyncCompleteWithinFrame"/>, this function returns /// <c>true</c> if the bitmap was corrently updated within the synchronous time frame and <c>false</c> otherwise. /// For every other mode, this function always returns <c>true</c>. /// </returns> public bool UpdateBitmap(byte[] pixels, LcdPriority priority, LcdUpdateMode updateMode) { if (pixels == null) { throw new ArgumentNullException("pixels"); } if (pixels.Length != PixelWidth * PixelHeight * BitsPerPixel / 8) { throw new ArgumentOutOfRangeException("pixels", "Pixels length is invalid for this device."); } VerifyValid(); try { return(UpdateBitmapCore(pixels, priority, updateMode)); } catch (Win32Exception) { // The device was invalidated between VerifyValid() and UpdateBitmapCore(), ignore if (_deviceNumber == -1) { return(false); } throw; } }
internal static bool LgLcdUpdateBitmapQvga(int device, byte[] pixels, LcdPriority priority, LcdUpdateMode updateMode) { Debug.Assert(pixels != null && pixels.Length == BmpQvgaWidth * BmpQvgaHeight * BmpQvgaBpp / 8); LgLcdBitmapQvga bitmap = new LgLcdBitmapQvga(pixels); int priorityAndUpdate = (int)priority | (int)updateMode; int result = IntPtr.Size == 8 ? LgLcdUpdateBitmap64(device, bitmap, priorityAndUpdate) : LgLcdUpdateBitmap32(device, bitmap, priorityAndUpdate); if (result != ErrorSuccess) { if (updateMode == LcdUpdateMode.SyncCompleteWithinFrame && result == ErrorAccessDenied) { return(false); } throw new Win32Exception(result); } return(true); }
/// <summary> /// Really updates a bitmap of the device. /// </summary> /// <param name="pixels">An array of pixels constituting the bitmap. See the SDK help for more information.</param> /// <param name="priority">Priority of the update.</param> /// <param name="updateMode">Update mode (synchronous or asynchronous).</param> /// <returns> /// If <paramref name="updateMode"/> is <see cref="LcdUpdateMode.SyncCompleteWithinFrame"/>, this function returns /// <c>true</c> if the bitmap was corrently updated within the synchronous time frame and <c>false otherwise</c>. /// For every other mode, this function always returns <c>true</c>. /// </returns> protected abstract bool UpdateBitmapCore(byte[] pixels, LcdPriority priority, LcdUpdateMode updateMode);
/// <summary> /// Really updates a bitmap of the device. /// </summary> /// <param name="pixels">An array of pixels constituting the bitmap. See the SDK help for more information.</param> /// <param name="priority">Priority of the update.</param> /// <param name="updateMode">Update mode (synchronous or asynchronous).</param> /// <returns> /// If <paramref name="updateMode"/> is <see cref="LcdUpdateMode.SyncCompleteWithinFrame"/>, this function returns /// <c>true</c> if the bitmap was corrently updated within the synchronous time frame and <c>false otherwise</c>. /// For every other mode, this function always returns <c>true</c>. /// </returns> protected override bool UpdateBitmapCore(byte[] pixels, LcdPriority priority, LcdUpdateMode updateMode) { return(SafeNativeMethods.LgLcdUpdateBitmapQvga(DeviceNumber, pixels, priority, updateMode)); }