make GDI drawing more efficient C# -
at moment code takes 10% of cpus power. how can make more efficient , less flickerish? code:
private void timer1_tick(object sender, eventargs e) { drawlocal(); thread.sleep(17); picturebox1.invalidate(); } private void drawlocal() { int localreadx = readaddress("hl2", "client.dll+0xbfff00 364 0"); int localready = readaddress("hl2", "client.dll+0xbfff00 368 0"); byte[] bytesoflocalx = bitconverter.getbytes(localreadx);//converts float byte[] bytesoflocaly = bitconverter.getbytes(localready);//converts float float localx = bitconverter.tosingle(bytesoflocalx, 0)/10;//converts float float localy = bitconverter.tosingle(bytesoflocaly, 0)/10;//converts float graphics localp = picturebox1.creategraphics(); localp.fillrectangle(new solidbrush(color.red), localx, localy, 5, 5); graphics localname = picturebox1.creategraphics(); localname.drawstring(" local", new font("arial", 7), new solidbrush(color.red), localx, localy); }
the comments above, demonstrated below:
private font f = new font("arial", 7); public form1() { initializecomponent(); picturebox1.paint += picturebox1_paint; } private void timer1_tick(object sender, eventargs e) { picturebox1.invalidate(); } void picturebox1_paint(object sender, painteventargs e) { int localreadx = readaddress("hl2", "client.dll+0xbfff00 364 0"); int localready = readaddress("hl2", "client.dll+0xbfff00 368 0"); byte[] bytesoflocalx = bitconverter.getbytes(localreadx);//converts float byte[] bytesoflocaly = bitconverter.getbytes(localready);//converts float float localx = bitconverter.tosingle(bytesoflocalx, 0) / 10;//converts float float localy = bitconverter.tosingle(bytesoflocaly, 0) / 10;//converts float e.graphics.fillrectangle(brushes.red, localx, localy, 5, 5); e.graphics.drawstring(" local", f, brushes.red, localx, localy); }
Comments
Post a Comment