1

ウィンドウに完全な画像を表示するためにwxHaskellを使用しています。私のコードは次のとおりです。

import Graphics.UI.WX
import Graphics.UI.WXCore

main :: IO ()
main = start testimg

testimg :: IO ()
testimg = do
  f <- frame [text := "Test Image"]
  p <- panel f []

  image <- bitmapCreateFromFile "landscape.png"
  imagep <- panel p [ on paint := onPaint image ]

  set f [ layout:= fill $ container p $ widget imagep ]

  where
    onPaint image dc rect = drawBitmap dc image pointZero True []

とにかく、アプリを実行すると何も表示されません (ウィンドウの境界線も表示されません)。どうすればそれを機能させることができますか?

4

1 に答える 1

2

写真でペイントしたパネルが表面にならないという効果で、fill前に見逃しました。widget imagepまた、outerSize も設定することをお勧めします。インスピレーションを得るために、https://github.com/wxHaskell/wxHaskell/blob/master/samples/wx/ImageViewer.hsもご覧ください。幸運を!

import Graphics.UI.WX
import Graphics.UI.WXCore

main :: IO ()
main = start testimg

testimg :: IO ()
testimg = do
  f <- frame [text := "Test Image"]
  p <- panel f []

  image <- bitmapCreateFromFile "landscape.png"
  imagep <- panel p [ on paint := onPaint image ]

  set f [ layout:= fill $ container p $ fill $ widget imagep 
        , outerSize := sz 500 500
        ]

  where
    onPaint image dc rect = drawBitmap dc image pointZero True []
于 2015-11-13T23:24:42.373 に答える