メインコンテンツへ飛ぶ

ImageView

画像を表示するビュー。

プロセス: メイン

app モジュールの ready イベントが発生するまでは、このモジュールは使用できません。

コンテンツの読み込みが完了したときに WebContentsView と入れ替わるスプラッシュスクリーンを表示するのに便利です。

注意として、ImageView は実験的なものであり、将来に変更または削除される可能性があります。

const { BaseWindow, ImageView, nativeImage, WebContentsView } = require('electron')

const path = require('node:path')

const win = new BaseWindow({ width: 800, height: 600 })

// WebContentsView の読み込み中に表示する「スプラッシュスクリーン」画像を作成します。
const splashView = new ImageView()
const splashImage = nativeImage.createFromPath(path.join(__dirname, 'loading.png'))
splashView.setImage(splashImage)
win.setContentView(splashView)

const webContentsView = new WebContentsView()
webContentsView.webContents.once('did-finish-load', () => {
// WebContentsView がロードされたので、「スプラッシュ スクリーン」の ImageView を入れ替えます。
win.setContentView(webContentsView)
})
webContentsView.webContents.loadURL('https://electronjs.org')

クラス: ImageView extends View

History
Version(s)Changes
None
API ADDED

画像を表示するビュー。

プロセス: メイン

ImageViewView から継承しています。

ImageViewEventEmitter を継承しています。

警告

Electron 組み込みのクラスはユーザコードでサブクラス化できません。 詳細については、FAQ をご参照ください。

new ImageView() 実験的

History
Version(s)Changes
None
API ADDED

ImageView を作成します。

インスタンスメソッド

View から継承されたメソッドに加えて、以下のメソッドが ImageView クラスのインスタンスで使用できます。

image.setImage(image) 実験的

History
Version(s)Changes
None
API ADDED
  • image NativeImage

この ImageView の画像をセットします。 注意として、ImageView では NativeImage がサポートする画像形式のみを使用できます。