From 1ff695873f1dc9cf880007df2b9b0f17c63a1281 Mon Sep 17 00:00:00 2001 From: hugovk Date: Wed, 16 Jul 2014 23:44:35 +0300 Subject: [PATCH 1/3] Cursor image by Miss Mycroft, 'Released under the Release to Public Domain license' http://www.rw-designer.com/cursor-detail/61757 --- Tests/images/deerstalker.cur | Bin 0 -> 4286 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Tests/images/deerstalker.cur diff --git a/Tests/images/deerstalker.cur b/Tests/images/deerstalker.cur new file mode 100644 index 0000000000000000000000000000000000000000..16e4bfa52e6c870feba0582df6812b668edf2ed3 GIT binary patch literal 4286 zcmeHJSxj727`{joTKj-jOVvby)>>-X#1|Wv)Im*4fxs{@Fw8K+Y|K9FGQ%<~Qn00z zrB-NC2BF3l($*IrTyPMONEm#u1vOf&vS^!-v=o$WxcC14=fD`+R46#{iJN?L)_eZ% zeE)KXVIE@qn2->LKJAY%Oc3_M5Fv0QJ25fw zhOarG#(@{w&yQFv1~8h^5Lz%<^q|vgz+}>cTAfO{BqWHyX3M)hG&H32B?r%fC#s;x z206JIkezFVtZXZ!XP6LXw5GG(570W1f^1rK1f2pBtw!!4AIe%5E*%dtExIa^;K`r2OiJ-3;%@& z&vPLytxoP}MJbe(JHVEo4QABeduOdy4KkU8`ar2tKw@G%gonQd3F3H&h&T+zCB^ey zU0qcepF7se!`1n@n`lsZtPJvOS&R0yDr#4yR#5Hbav5#KViDRsgt{nD6B*?ZD~yG@ z`r2P_-2B6W@f3>iTML(w(cgsir%tjJm8DSRuv7bby%vZM$o=JVDM%zFCsHT}p)dwi zDvV2v2@P4t`M9`PP+`0@InT1=Rs1G&FiqX4tn00u)E1<^r; zd1y4~(2fjsms0)pxSo}rLHCl_XlOh=P3ouj%(b@ouArvw1m@VHU2->_PK(f>-U`Zr z+@EMe^3rNGK}Mz(ELJ1U)k~Kz_F)ZQlkb;v#9Y|ce(}P%HQh*kPxLpN7yE>V0q>8s z5dC8Y6Y4|m{#ITN-6KBMF8QCtKhZb^eVmbLfjoOI zjT6Fy=uuc?pPQV#b6_Q#PcqCkToD1ur?D*&b@(!?QPOrw{$De+%pRBFo@@zSvH)tU~A&%BPQM?d@aWP;o z$e}Sp=E?Z|mgb-F`;FII^#ODcJk2m3+zA9rn%wmw-eYrbZ;y-QVrG^Fq_QM9bofnL zcf!J+gM$ZOftOxBfVD?Ne9yW%UBg$deEad}*vNL6|@!sBDBcsEK&Sq!dnKKPHk5-gVz1MJhw)I>~&*0Eim3PlN+ke&k-t$mXKLBnM z4;;}ITXx-b#e4Qrtc82W|91-y_}mEq;28jxDTO&kfCxnRBN&`xf|nrRv6f&G5#XN( crc{6k?q Date: Wed, 16 Jul 2014 23:45:18 +0300 Subject: [PATCH 2/3] Sanity test for CurImagePlugin.py --- Tests/test_file_cur.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Tests/test_file_cur.py diff --git a/Tests/test_file_cur.py b/Tests/test_file_cur.py new file mode 100644 index 000000000..5dc096968 --- /dev/null +++ b/Tests/test_file_cur.py @@ -0,0 +1,23 @@ +from helper import unittest, PillowTestCase + +from PIL import Image, CurImagePlugin + + +class TestFileCur(PillowTestCase): + + def test_sanity(self): + # Arrange + test_file = "Tests/images/deerstalker.cur" + + # Act + im = Image.open(test_file) + + # Assert + self.assertEqual(im.size, (32, 32)) + self.assertIsInstance(im, CurImagePlugin.CurImageFile) + + +if __name__ == '__main__': + unittest.main() + +# End of file From 9acbaa4aeecd7a6fed957a7e20c27cda5bd88caf Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 17 Jul 2014 00:12:54 +0300 Subject: [PATCH 3/3] Flake8 and fix typo --- PIL/CurImagePlugin.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/PIL/CurImagePlugin.py b/PIL/CurImagePlugin.py index 4cf2882e2..0178957ee 100644 --- a/PIL/CurImagePlugin.py +++ b/PIL/CurImagePlugin.py @@ -33,6 +33,7 @@ i32 = _binary.i32le def _accept(prefix): return prefix[:4] == b"\0\0\2\0" + ## # Image plugin for Windows Cursor files. @@ -48,7 +49,7 @@ class CurImageFile(BmpImagePlugin.BmpImageFile): # check magic s = self.fp.read(6) if not _accept(s): - raise SyntaxError("not an CUR file") + raise SyntaxError("not a CUR file") # pick the largest cursor in the file m = b"" @@ -58,14 +59,14 @@ class CurImageFile(BmpImagePlugin.BmpImageFile): m = s elif i8(s[0]) > i8(m[0]) and i8(s[1]) > i8(m[1]): m = s - #print "width", i8(s[0]) - #print "height", i8(s[1]) - #print "colors", i8(s[2]) - #print "reserved", i8(s[3]) - #print "hotspot x", i16(s[4:]) - #print "hotspot y", i16(s[6:]) - #print "bytes", i32(s[8:]) - #print "offset", i32(s[12:]) + # print "width", i8(s[0]) + # print "height", i8(s[1]) + # print "colors", i8(s[2]) + # print "reserved", i8(s[3]) + # print "hotspot x", i16(s[4:]) + # print "hotspot y", i16(s[6:]) + # print "bytes", i32(s[8:]) + # print "offset", i32(s[12:]) # load as bitmap self._bitmap(i32(m[12:]) + offset) @@ -73,7 +74,7 @@ class CurImageFile(BmpImagePlugin.BmpImageFile): # patch up the bitmap height self.size = self.size[0], self.size[1]//2 d, e, o, a = self.tile[0] - self.tile[0] = d, (0,0)+self.size, o, a + self.tile[0] = d, (0, 0)+self.size, o, a return