Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'argument': 0.04; 'birmingham': 0.04; 'bits': 0.07; 'width': 0.07; 'page)': 0.09; "they've": 0.09; 'useless': 0.09; 'stored': 0.10; '(like': 0.15; '-tkc': 0.16; 'disclaimers': 0.16; 'kings': 0.16; 'png': 0.16; 'reversing': 0.16; 'scientist': 0.16; 'thoughts?': 0.16; 'trainee': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'message-----': 0.17; 'received:169.254.1': 0.17; 'tim': 0.18; 'windows': 0.19; '(not': 0.20; 'file.': 0.20; 'foundation': 0.20; 'trying': 0.21; 'bit': 0.21; 'earlier': 0.21; 'disclaimer': 0.22; "world's": 0.22; "i'd": 0.22; 'proprietary': 0.23; "i've": 0.23; 'received:169.254': 0.24; 'header': 0.24; 'header:In-Reply-To:1': 0.25; 'donate': 0.27; 'chase': 0.29; 'dimensions': 0.29; 'received:169': 0.29; "i'm": 0.29; "we're": 0.30; 'error': 0.30; '+44': 0.30; 'skip:- 10': 0.32; 'could': 0.32; 'print': 0.32; 'anyone': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'text': 0.34; 'robert': 0.35; 'posting': 0.35; 'something': 0.35; 'subject:': 0.36; '(i.e.': 0.36; 'display': 0.36; 'author': 0.37; 'best,': 0.37; 'does': 0.37; 'two': 0.37; 'detail': 0.37; 'sent:': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'university': 0.38; 'from:': 0.38; 'object': 0.38; 'some': 0.38; 'possible.': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'recipient': 0.39; 'where': 0.40; 'most': 0.61; 'remove': 0.61; 'further': 0.61; 'save': 0.61; 'email:': 0.62; 'header:Message- Id:1': 0.62; 'received:62': 0.62; 'information,': 0.63; 'more': 0.63; 'replying': 0.64; 'our': 0.65; 'legal': 0.65; 'tel:': 0.65; 'medical': 0.66; 'reply': 0.66; 'e-mail.': 0.71; 'privileged.': 0.72; 'exclusive': 0.81; '2013': 0.84; '7000': 0.84; 'bitmap': 0.84; 'cancer': 0.84; 'clinical': 0.84; 'standing': 0.84; 'hospitals': 0.91; 'treatments': 0.91; 'recipient(s)': 0.96 From: Robert Flintham To: "'python-list@python.org'" Date: Tue, 12 Mar 2013 13:31:28 +0000 Subject: RE: Reversing bits in a byte Thread-Topic: Reversing bits in a byte Thread-Index: Ac4fJC1teCeYVtUWTH2+fU4PkpvO/QAAVLsg OLD-MSG-ID: References: <20130311153254.078484489A7@nhs-pd1e-esg101.ad1.nhs.net> <20130312131906.C4FC444A193@nhs-pd1e-esg002.ad1.nhs.net> In-Reply-To: <20130312131906.C4FC444A193@nhs-pd1e-esg002.ad1.nhs.net> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, en-GB Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SEF-7853D99-ADF1-478E-8894-213D316B8FFA: 1 X-SEF-Processed: 7_0_0_00239__2013_03_12_13_31_29 X-TM-AS-Product-Ver: IMSVA-8.0.0.1467-7.0.0.1014-19710.007 X-TM-AS-Result: No--25.012-60-31-10 X-imss-scan-details: No--25.012-60-31-10; No--25.012-3-31-10; No--25.012-5-31-10 X-TMASE-MatchedRID: kDGVTvftZfq+J2V2/n6KGWOho7buv7d9MC4zO7d4kaPjud2x7TPVtzWQ bTjGG0mtTyCN0u3yL9slXb+aEknTCSQAlMLSCGRUlQk/u8XKetEuRnZA6PlcxluVDt57bLZpm6V hvSGZ1UCWjiti7ndJY/umyOC/eNMccQH03dPWKdnRXhA4ma+s3vLHLpWeDUKtyXL+j1Hy+/EGZM dDwU3lWRKka+YVEX1SV/OhPFxONvMgy+t8MbJ2WMzWN98iBBeGF2pUb6YRYK4g2z9E1gvBRHcdb 6NrA6kc1Fc61VCGvh2caaKFfnN28pIOhgOZiPMs/c0+LJTMrN0Tc3GwbO2sy8Cgp9YTxGzniZsl gYzLMZCzR95c6Z6RobfVbQM3em660ZoaLxGqAAC8coKUcaOOvTFcf92WG8u/PTCcnLPez2sVRzu FxispLmgPILWMmI4XdUAulK0GzSreO/gq9avCxADPuhU4P53K+q1Y+/eEArZeRkGJLdC+6i57hW H2lkqmggANnVC0TIm1ULtRjWfrIpBlLa6MK1y4 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363095093 news.xs4all.nl 6910 [2001:888:2000:d::a6]:52614 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41120 Further to my earlier reply to Dave:=0D=0A=0D=0AI'd like to either display = the image in a GUI, or save it in a format that can be opened easily in Win= dows (like a PNG or a 24-bit BMP).=0D=0A=0D=0AI know the dimensions as it's= coming from the header of a DICOM file. I'm trying to analyse DICOM image= s where an 'overlay' image is stored as a bitmap in the header information.= So the bitmap data is one DICOM tag (6000,3000) and the height and width = of the overlay are in two other tags (6000,0010) and (6000,0011).=0D=0A=0D=0A= All the best,=0D=0ARob=0D=0A=0D=0ARobert Flintham=0D=0ATrainee Clinical Sci= entist - MRI=0D=0A=0D=0ATel: +44 (0)121 371 7000=0D=0AEmail: Rob= ert.Flintham@uhb.nhs.uk=0D=0AWeb: http://www.uhb.nhs.uk=0D=0A=0D=0AWe'= re bringing the world's most advanced cancer treatments to Birmingham.=0D=0A= Find out more at www.qecancerappeal.org or text QEHB01 =A35 to 70070 to don= ate =A35 to our appeal.=0D=0A=0D=0ARRPPS=0D=0AMedical Physics - University = Hospitals Birmingham NHS Foundation Trust=0D=0A63 Melchett Road, Kings Nort= on,=0D=0ABirmingham, B30 3HP=0D=0A=0D=0A=0D=0A=F0 Delivering the best in ca= re=0D=0A=0D=0A=0D=0A=0D=0A-----Original Message-----=0D=0AFrom: Tim Chase [= mailto:python.list@tim.thechases.com]=20=0D=0ASent: 12 March 2013 13:21=0D=0A= To: Robert Flintham=0D=0ACc: 'python-list@python.org'=0D=0ASubject: Re: Rev= ersing bits in a byte=0D=0A=0D=0AOn 2013-03-11 15:32, Robert Flintham wrote= :=0D=0A> I have a 'bytes' object which contains a simple bitmap image (i.e.=0D= =0A> 1 bit per pixel). I can't work out how I would go about displaying =0D= =0A> this image. Does anyone have any thoughts=3F=0D=0A=0D=0AYou'd need to= detail=0D=0A- how you want to display it (console, GUI, web page)=0D=0A- h= ow you know what the dimensions are=0D=0A- the bit order=0D=0A=0D=0AIt coul= d be something as simple as=0D=0A=0D=0A HEIGHT =3D 40=0D=0A some=5Fbytes = =3D file('data.bin').read()=0D=0A WIDTH =3D len(some=5Fbytes) // HEIGHT=0D= =0A for i, byte in enumerate(some=5Fbytes):=0D=0A if i and i % WIDTH =3D= =3D 0:=0D=0A print # a new line=0D=0A for bit in range(8):=0D=0A = if byte & (1 << bit):=0D=0A print '*',=0D=0A else:=0D=0A = print ' ',=0D=0A=0D=0A=0D=0A-tkc=0D=0A=0D=0A> DISCLAIMER:=0D=0A[trim a = paragraph of useless junk]=0D=0APlease remove these disclaimers if at all p= ossible. You're posting to a public forum, which pretty much waives all cr= edibility to the disclaimer (not that they've held much legal standing in a= ny argument I've heard).=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0ADISCLAIME= R:=0D=0AThis email and any attachments hereto contains proprietary informat= ion, some or all of which may be confidential or legally privileged. It is = for the exclusive use of the intended recipient(s) only. If an addressing o= r transmission error has misdirected this e-mail and you are not the intend= ed recipient(s), please notify the author by replying to this e-mail. If yo= u are not the intended recipient you must not use, disclose, distribute, co= py, print, or rely on this e-mail or any attachments, as this may be unlawf= ul.=0D=0A