wxImage->wxBitmap変換
2005年12月14日昨日のwxImage->wxBitmapへの変換だが、どうも
wxBitmap(void* data, int type, int width, int height, int depth = -1);
と
wxBitmap(const wxImage& img, int depth = -1);
で処理時間が変わってくるようだ。
マニュアルでは
wxBitmap( const wxImage&img, int depth = -1) Creates bitmap object from the image. This has to be done to actually display an image as you cannot draw an image directly on a window. The resulting bitmap will use the provided colour depth (or that of the current system if depth is -1) which entails that a colour reduction has to take place. When in 8-bit mode (PseudoColour mode), the GTK port will use a color cube created on program start-up to look up colors. This ensures a very fast conversion, but the image quality won’t be perfect (and could be better for photo images using more sophisticated dithering algorithms). On Windows, if there is a palette present (set with SetPalette), it will be used when creating the wxBitmap (most useful in 8-bit display mode). On other platforms, the palette is currently ignored.
と書かれている。このコンストラクタはwxImage->wxBitmapの変換を高速に行ってくれるが、変換のアルゴリズムはあまり良くないらしい。フォトイメージに関してはもっと優れたディザリングアルゴリズムを用いるべきだとも書いてある。
一応、検証してみたが後者は、前者の二倍近い高速化が昨日と同様の環境で確認できた(24(ms)->12(ms))。
画面で見た感じ、イメージの劣化は特に感じられなかった(適当な推論ではあるが)。
で、今頃気付いたのだが、デバッグモードでコンパイルした速度を測定したいたので、とりあえずリリースモードでコンパイルした場合の測定結果も示しておく。
リリースモードでは、平均して8(ms)程度で変換が可能だった。fpsでは125程度。なかなかの数値だと思う。
試しに、少し遅めのマシンでも試してみた。CPUはPentiumIII500MHz、WindowsXPのマシンでは同様のプログラムでの測定結果は20(ms)となった。fpsでは50fpsとなる。うーむ、これくらいならいけるんじゃないだろうか。
wxBitmap(void* data, int type, int width, int height, int depth = -1);
と
wxBitmap(const wxImage& img, int depth = -1);
で処理時間が変わってくるようだ。
マニュアルでは
wxBitmap( const wxImage&img, int depth = -1) Creates bitmap object from the image. This has to be done to actually display an image as you cannot draw an image directly on a window. The resulting bitmap will use the provided colour depth (or that of the current system if depth is -1) which entails that a colour reduction has to take place. When in 8-bit mode (PseudoColour mode), the GTK port will use a color cube created on program start-up to look up colors. This ensures a very fast conversion, but the image quality won’t be perfect (and could be better for photo images using more sophisticated dithering algorithms). On Windows, if there is a palette present (set with SetPalette), it will be used when creating the wxBitmap (most useful in 8-bit display mode). On other platforms, the palette is currently ignored.
と書かれている。このコンストラクタはwxImage->wxBitmapの変換を高速に行ってくれるが、変換のアルゴリズムはあまり良くないらしい。フォトイメージに関してはもっと優れたディザリングアルゴリズムを用いるべきだとも書いてある。
一応、検証してみたが後者は、前者の二倍近い高速化が昨日と同様の環境で確認できた(24(ms)->12(ms))。
画面で見た感じ、イメージの劣化は特に感じられなかった(適当な推論ではあるが)。
で、今頃気付いたのだが、デバッグモードでコンパイルした速度を測定したいたので、とりあえずリリースモードでコンパイルした場合の測定結果も示しておく。
リリースモードでは、平均して8(ms)程度で変換が可能だった。fpsでは125程度。なかなかの数値だと思う。
試しに、少し遅めのマシンでも試してみた。CPUはPentiumIII500MHz、WindowsXPのマシンでは同様のプログラムでの測定結果は20(ms)となった。fpsでは50fpsとなる。うーむ、これくらいならいけるんじゃないだろうか。
コメント