Вот метод, который (по моему опыту) по крайней мере в четыре раза быстрее, чем CreateBitmapSourceFromHBitmap
.
Требуется установить правильный PixelFormat
результирующего BitmapSource.
public BitmapSource Convert(System.Drawing.Bitmap bitmap)
{
var bitmapData = bitmap.LockBits(
new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat);
var bitmapSource = BitmapSource.Create(
bitmapData.Width, bitmapData.Height,
bitmap.HorizontalResolution, bitmap.VerticalResolution,
PixelFormats.Bgr24, null,
bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, bitmapData.Stride);
bitmap.UnlockBits(bitmapData);
return bitmapSource;
}
Я предполагаю, что вы пытаетесь реализовать маршруты, использующие разделение кода и асинхронную загрузку компонентов, когда они требуются, с экраном загрузки?
https://vuejs.org/v2/guide /components-dynamic-async.html#Handling-Loading-State
const AsyncComponent = () => ({
// The component to load (should be a Promise)
component: import('./MyComponent.vue'),
// A component to use while the async component is loading
loading: LoadingComponent,
// A component to use if the load fails
error: ErrorComponent,
// Delay before showing the loading component. Default: 200ms.
delay: 200,
// The error component will be displayed if a timeout is
// provided and exceeded. Default: Infinity.
timeout: 3000
})
let router = new Router({
routes: [
{
name: 'example',
path: '/example',
component: AsyncComponent,
},
]
})