小编Ant*_*nov的帖子

使用Codec.BMP时"无法将预期类型与实际类型匹配"错误

我在Haskell的经验非常少,我想为练习编写一个简单的光线跟踪器.因为我不想使用像wxHaskell这样的GUI工具(我认为要花很多时间学习如何使用它们),所以我决定只将输出图像保存到BMP文件中.但我这里有一个问题:

module Main where

import Codec.BMP
import qualified Data.ByteString as BS

main = do
  Right bmp <- readBMP "grass.bmp"
  BS.putStrLn $ BS.take 4 $ unpackBMPToRGBA32 bmp
Run Code Online (Sandbox Code Playgroud)

在这里,我只想拍摄图像的第一个像素并打印其RGBA值.但我得到一个错误说

Couldn't match expected type `BS.ByteString'
            with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString'
In the return type of a call of `unpackBMPToRGBA32'
In the second argument of `($)', namely `unpackBMPToRGBA32 bmp'
In the second argument of `($)', namely
  `BS.take 4 $ unpackBMPToRGBA32 bmp'
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?如何获取图像的像素并打印其值?

haskell

5
推荐指数
1
解决办法
1650
查看次数

如何在MacOS X上的Xamarin Studio中的Content.Load <Texture2D>中修复MissingMethodException?

我正在尝试使用Xamarin Studio 4.0.10(版本5)中的MonoGame创建一个简单的程序.但是当我尝试使用Content.Load方法加载一些纹理时,我收到一条System.MissingMethodException带有消息的异常

Method not found: 'MonoMac.AppKit.NSImage.AsCGImage'.
Run Code Online (Sandbox Code Playgroud)

我使用的实际代码行是:

protected override void LoadContent()
{
    //some stuff here

    Texture2D freezeTexts = new Texture2D[5];
    for (int i = 0; i < 5; i++) {
        freezeTexts[i] = Content.Load<Texture2D>("freeze"+i); // exception here
    }

    //some other stuff here
}
Run Code Online (Sandbox Code Playgroud)

我做了一些谷歌搜索,发现这是因为一些API更改,Xamarin Studio尚未实现(至少这是我所理解的).所以我的问题是:我该如何解决这个问题?

c# macos mono monogame xamarin-studio

5
推荐指数
1
解决办法
562
查看次数

标签 统计

c# ×1

haskell ×1

macos ×1

mono ×1

monogame ×1

xamarin-studio ×1