mono / xwt

A cross-platform UI toolkit for creating desktop applications with .NET and Mono
MIT License
1.37k stars 241 forks source link

Raw image RGB image access not found #656

Open ShadowTeolog opened 7 years ago

ShadowTeolog commented 7 years ago

For connection Xilium.CefGlue need to directly write RGB32 value to image and show it in window. But currently don't see any way for cross platform write to existing Xwt.Drawing.Image data. Curently only can get native backend and access directly using it. This make bakend lock.

slluis commented 7 years ago

You can access to pixel RGB data using the BitmapImage class.

ShadowTeolog commented 7 years ago

Don't see any way now. GetPixel,SetPixel,CopyArea to another BitmapImage. No raw buffer access here. Or you tell me to use SetPixel with 1280x1024 image many times in second? In original WPF version used Media.Imaging.WriteableBitmap. WritePixels(sourceRect, sourceBuffer, sourceBufferSize, stride, (int)dirtyRect.X, (int)dirtyRect.Y); Write many times with different areas But here I can't get access to any buffer.

slluis commented 7 years ago

Yes, the only available API right now is GetPixel/SetPixel.

sevoku commented 7 years ago

There is not direct buffer access in Xwt because the backends handle it in very different ways. You could retrieve the backend from Xwt.Image by using Toolkit.CurrentEngine.GetNativeImage (Image) and do the required operations directly on the backend object, but for this you'll need to use platform specific code (BitmapImage in WPF, NSImage in Cocoa and Pixbuf in Gtk).

ShadowTeolog commented 7 years ago

Currently use WrapImage from pre-rendered source. Slow, but working. Will return to this problem after few months. Toolkit.CurrentEngine.GetNativeImage returned BitmapSource only allow reading :)