<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>glReadPixels &#8211; WANGXUCHAO.CN</title>
	<atom:link href="https://www.wangxuchao.cn/tag/glreadpixels/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wangxuchao.cn</link>
	<description></description>
	<lastBuildDate>Sun, 17 Dec 2017 15:15:50 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>解决Android中通过glReadPixels获取像素颜色不对的问题</title>
		<link>https://www.wangxuchao.cn/%e8%a7%a3%e5%86%b3android%e4%b8%ad%e9%80%9a%e8%bf%87glreadpixels%e8%8e%b7%e5%8f%96%e7%9a%84%e9%a2%9c%e8%89%b2%e4%b8%8d%e5%af%b9%e7%9a%84%e9%97%ae%e9%a2%98/</link>
		
		<dc:creator><![CDATA[wangxuchao]]></dc:creator>
		<pubDate>Sun, 29 Oct 2017 20:00:41 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[glReadPixels]]></category>
		<guid isPermaLink="false">http://www.wangxuchao.cn/?p=17</guid>

					<description><![CDATA[if (YayoGameMidlet.shotScreen) { // GL to Android Bitma &#8230; <p class="link-more"><a href="https://www.wangxuchao.cn/%e8%a7%a3%e5%86%b3android%e4%b8%ad%e9%80%9a%e8%bf%87glreadpixels%e8%8e%b7%e5%8f%96%e7%9a%84%e9%a2%9c%e8%89%b2%e4%b8%8d%e5%af%b9%e7%9a%84%e9%97%ae%e9%a2%98/" class="more-link">继续阅读<span class="screen-reader-text">“解决Android中通过glReadPixels获取像素颜色不对的问题”</span></a></p>]]></description>
										<content:encoded><![CDATA[<p><code><br />
if (YayoGameMidlet.shotScreen) {<br />
// GL to Android Bitmap Color Modifier values.<br />
final float[] cmVals = {<br />
0, 0, 1, 0, 0,<br />
0, 1, 0, 0, 0,<br />
1, 0, 0, 0, 0,<br />
0, 0, 0, 1, 0,<br />
};</code><span id="more-17"></span></p>
<p>// Collect the pixels from the GLSurfaceView.<br />
int x = 0;<br />
int y = 0;<br />
int w = YayoGameMidlet.screenWidth;<br />
int h = YayoGameMidlet.screenHeight;<br />
int[] pix = new int[w * h];<br />
IntBuffer PixelBuffer = IntBuffer.wrap(pix);<br />
PixelBuffer.position(0);<br />
gl.glReadPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, PixelBuffer);<br />
Bitmap glBitmap = Bitmap.createBitmap(pix, w, h, Bitmap.Config.ARGB_8888);<br />
PixelBuffer = null;<br />
pix = null;</p>
<p>// Translate pixel colors to make them android compatible.<br />
Paint paint = new Paint();<br />
paint.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix(cmVals)));<br />
Bitmap newImage = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);<br />
Canvas canvas = new Canvas(newImage);<br />
canvas.drawBitmap(glBitmap, 0, 0, paint);<br />
glBitmap.recycle();<br />
glBitmap = null;</p>
<p>// Generate the overlay from the modified pixels with the help of a matrix.<br />
Matrix matrix = new Matrix();<br />
matrix.preScale(1.0f, -1.0f); // Vertical flip.<br />
YayoGameMidlet.screenBmp = Bitmap.createBitmap(newImage, 0, 0, newImage.getWidth(), newImage.getHeight(), matrix, true);<br />
newImage.recycle();<br />
newImage = null;</p>
<p>// Done capturing overlay.<br />
YayoGameMidlet.shotScreen = false;<br />
}</p>
<p><a href="https://www.programcreek.com/java-api-examples/index.php?class=javax.microedition.khronos.opengles.GL10&amp;method=glReadPixels" target="_blank" rel="noopener">参考链接</a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
