2011-01-31 2 views
1

이전 테스트에서 사용했던 테스트가 있습니다. (Windows Vista Ultimate 32 비트)Image.FromStream이 새로운 Windows 설치에서 동일한 방식으로 작동하지 않습니다.

private static readonly byte[] TEST_BMP = new byte[] 
    { 
     0x42, 0x4D, 0x7E, 0, 0, 0, 0, 0, 0, 0, 0x76, 0, 0, 0, 0x28, 0, 0, 0, 0x2, 
     0, 0, 0, 0x2, 0, 0, 0, 0x1, 0, 0x4, 0, 0, 0, 0, 0, 0x8, 0, 0, 0, 0, 0, 0, 
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0, 0x80, 
     0, 0, 0, 0x80, 0x80, 0, 0x80, 0, 0, 0, 0x80, 0, 0x80, 0, 0x80, 0x80, 0, 0, 
     0x80, 0x80, 0x80, 0, 0xC0, 0xC0, 0xC0, 0, 0, 0, 0xFF, 0, 0, 0xFF, 0, 0, 0, 
     0xFF, 0xFF, 0, 0xFF, 0, 0, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0xFF, 0, 0, 0xFF, 
     0xFF, 0xFF, 0, 0x40, 0, 0, 0, 0xF9, 0, 0 
    }; 

[Test] 
public void Can_get_Image_from_BMP_Stream() 
{ 
    using (var memStream = new MemoryStream(TEST_BMP)) 
    { 
     Image image = Image.FromStream(memStream); 
     Assert.NotNull(image); 
    } 
} 

내 새 컴퓨터 (Windows 7 64 비트)에서는 더 이상 작동하지 않습니다. ... 작동이와

System.ArgumentException : Parameter is not valid. 
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) 
at System.Drawing.Image.FromStream(Stream stream) 
at Litium.Framework.Image.Test.ImageManagerTests.Can_get_Image_from_BMP_Stream() 

내가 대신하려고하면

private static readonly byte[] TEST_GIF = new byte[] 
    { 
     0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x2, 0, 0x2, 0, 0x11, 0, 0, 0x2C, 0, 0 
     , 0, 0, 0x2, 0, 0x2, 0, 0xA1, 0xFF, 0, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 
     0x80, 0x2, 0x3, 0xC, 0x26, 0x5, 0, 0x3B 
    }; 

하지 않는 이유는 내 새 컴퓨터에이 작품 :

나는이 예외가?

답변

1

끝에 0 바이트를 추가하려고 했습니까? 나는 그것에 대해 좋은 느낌을 가지고있다!

+0

Tack Daniel! 그게 도움이되었지만 이제는 더 간단하게 바뀔 것입니다 : private static readonly byte [] TEST_BMP = File.ReadAllBytes ("test.bmp"); :) – Allrameest

+0

모험심 만큼은 아니지만 그것을 허용 할 것입니다. – Sciolist

관련 문제