<html>
<body>
<font color="#800000">Something like?<br><br>
</font><tt>&gt;&gt;&gt; a=numpy.array([1,2,3,4,5,6,7,8])<br>
&gt;&gt;&gt; b=a.reshape(2,4).copy()<br>
&gt;&gt;&gt; b<br>
array([[1, 2, 3, 4],<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [5, 6, 7, 8]])<br>
&gt;&gt;&gt; b[:,0]=a.reshape(2,4)[:,2].copy()<br>
&gt;&gt;&gt; b[:,2]=a.reshape(2,4)[:,0].copy()<br>
&gt;&gt;&gt; b<br>
array([[3, 2, 1, 4],<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [7, 6, 5, 8]])<br>
</tt><font color="#800000">See also
<a href="http://www.mail-archive.com/numpy-discussion@scipy.org/msg18651.html" eudora="autourl">
http://www.mail-archive.com/numpy-discussion@scipy.org/msg18651.html<br>
</a>Ray<br><br>
</font>At 11:53 AM 5/31/2011, Tim Roberts wrote:<br>
<blockquote type=cite class=cite cite="">Greg Ewing wrote:<br>
&gt; Can anyone think of an efficient way to convert a string<br>
&gt; full of RGBA image data to BGRA, using only what's available<br>
&gt; in the standard library?<br>
&gt;<br>
&gt; I'm trying to add a function to PyGUI for creating an Image<br>
&gt; object from arbitrary data. The problem I'm having is that<br>
&gt; GDI+ on Windows expects BGRA, whereas most other platforms<br>
&gt; deal with RGBA. I don't want to require the user to supply<br>
&gt; the data in different formats on different platforms, so<br>
&gt; PyGUI needs to be able to convert where necessary.<br>
&gt;<br>
&gt; I know the conversion can be done easily using something<br>
&gt; like PIL or numpy, but I'm after a solution that doesn't<br>
&gt; depend on any third-party libraries.<br><br>
Nothing other than brute force.<br><br>
&nbsp; bout = []<br>
&nbsp; for i in range(0,len(bin),4):<br>
&nbsp;&nbsp;&nbsp; bout.extend( [bin[i+2], bin[i+1], bin[i], bin[i+3])
)<br><br>
It ain't gonna be quick.&nbsp; If it were me, I'd rather ship
PIL.<br><br>
-- <br>
Tim Roberts, timr@probo.com<br>
Providenza &amp; Boekelheide, Inc.<br><br>
_______________________________________________<br>
python-win32 mailing list<br>
python-win32@python.org<br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" eudora="autourl">
http://mail.python.org/mailman/listinfo/python-win32</a></blockquote>
</body>
</html>