Comments (13)
same problem on Nexus S
Original comment by g.jjoe64
on 29 Jun 2011 at 2:50
Attachments:
from android-screenshot-library.
Similar issue I faces on HTC G2, Nexus S, Samsung Vibrant +. Any solution pls.
Original comment by [email protected]
on 29 Jul 2011 at 7:18
from android-screenshot-library.
[deleted comment]
from android-screenshot-library.
[deleted comment]
from android-screenshot-library.
could you please tell me the fix?
Original comment by g.jjoe64
on 28 Nov 2011 at 7:08
from android-screenshot-library.
private Screenshot retreiveRawScreenshot() throws Exception {
try {
// connect to native application
//We use SocketChannel,because is more convenience and fast
SocketChannel socket = SocketChannel.open(new InetSocketAddress("localhost", PORT));
socket.configureBlocking(false);
//Send Commd to take screenshot
ByteBuffer cmdBuffer = ByteBuffer.wrap("SCREEN".getBytes("ASCII"));
socket.write(cmdBuffer);
//build a buffer to save the info of screenshot
//3 parts,width height cpp
byte[] info = new byte[3 + 3 + 2 + 2];//3 bytes width + 1 byte space + 3 bytes heigh + 1 byte space + 2 bytes bpp
ByteBuffer infoBuffer = ByteBuffer.wrap(info);
//we must make sure all the data have been read
while(infoBuffer.position() != infoBuffer.limit())
socket.read(infoBuffer);
//we must read one more byte,because after this byte,we will read the image byte
socket.read(ByteBuffer.wrap(new byte[1]));
//set the position to zero that we can read it.
infoBuffer.position(0);
StringBuffer sb = new StringBuffer();
for(int i = 0;i < (3 + 3 + 2 + 2);i++)
{
sb.append((char)infoBuffer.get());
}
String[] screenData = sb.toString().split(" ");
if (screenData.length >= 3) {
Screenshot ss = new Screenshot();
ss.width = Integer.parseInt(screenData[0]);
ss.height = Integer.parseInt(screenData[1]);
ss.bpp = Integer.parseInt(screenData[2]);
// retreive the screenshot
// (this method - via ByteBuffer - seems to be the fastest)
ByteBuffer bytes = ByteBuffer.allocate (ss.width * ss.height * ss.bpp / 8);
while(bytes.position() != bytes.limit())
{
//in the cycle,we must make sure all the image data have been read,maybe sometime the socket will delay a bit time and return some invalid bytes.
socket.read(bytes); // reading all at once for speed
}
bytes.position(0); // reset position to the beginning of ByteBuffer
ss.pixels = bytes;
return ss;
}
}
catch (Exception e) {
throw new Exception(e);
}
finally {}
return null;
}
Original comment by [email protected]
on 8 Dec 2011 at 1:56
from android-screenshot-library.
It's work, thanks a lot.
Original comment by [email protected]
on 9 Dec 2011 at 3:45
from android-screenshot-library.
Thanks a lot!!
Original comment by [email protected]
on 15 Jul 2012 at 10:03
from android-screenshot-library.
thanks it works
Original comment by [email protected]
on 4 Sep 2012 at 12:11
from android-screenshot-library.
What is the correct PORT? and What is the Screenshot object?
Original comment by [email protected]
on 21 Jan 2013 at 11:29
from android-screenshot-library.
/*
* Port number used to communicate with native process.
*/
private static final int PORT = 42380;
Please check ScreenshotService.java for above details, and better understanding
use demo project from download.
Original comment by [email protected]
on 22 Jan 2013 at 3:34
from android-screenshot-library.
what is < and > in ur code
Original comment by [email protected]
on 28 Feb 2013 at 4:39
from android-screenshot-library.
I saw this issue lately! I fixed this issue by modifying original source below
"part of retreiveRawScreenshot moethod"
org:
// retreive the screenshot
// (this method - via ByteBuffer - seems to be the fastest)
ByteBuffer bytes = ByteBuffer.allocate (ss.width * ss.height * ss.bpp / 8);
is = new BufferedInputStream(is); // buffering is very important apparently
is.read(bytes.array()); // reading all at once for speed
bytes.position(0); // reset position to the beginning of ByteBuffer
ss.pixels = bytes;
modify:
/*
* BufferedInputStream default providing buff size
*/
private static final int BUF_SIZE = 8192;
ByteBuffer bytes = ByteBuffer.allocate (ss.width * ss.height * ss.bpp / 8);
is = new BufferedInputStream(is);// buffering is very important apparently
bytes.position(0);
while(true) {
final int remain_size = bytes.limit() - bytes.position();
if (remain_size > BUF_SIZE) {
is.read(bytes.array(), bytes.position(), BUF_SIZE);
bytes.position(bytes.position() + BUF_SIZE);
} else {
is.read(bytes.array(), bytes.position(), remain_size);
bytes.position(0);
break;
}
}
ss.pixels = bytes;
the key is, not reading buffer at once. I fix reading whole of data explicitly.
It could be slow but handler would not cause ANR and that is what I
intended(entirely full screen), thanks!
Original comment by [email protected]
on 18 Mar 2014 at 2:15
from android-screenshot-library.
Related Issues (20)
- screen shots can be successful, but, asl-native service is stopped,It "shows Native service not found", after the start of each service only successful of one time HOT 10
- screen shots can be successful, but, asl-native service is stopped,It "shows Native service not found", after the start of each service only successful of one time HOT 1
- Screenshot height each time is fixed, and only shows the head of the phone screen HOT 2
- (patch) native part does not compile in release
- Black screen on Samsung Galaxy Note (N7000)
- Getting black screen on ANdroid 2.2 emulator HOT 1
- Black screen is capturing in emulator
- Nexus 7 produces "fuzzy" image screenshot HOT 1
- Can anyone send me fix asl 1.2?
- failed to copy './asl-native' to '/data/local/asl-native': Permission denied
- For some devices No screenshot will be taken HOT 1
- Screenshots of Videos
- magic 7F45
- Black screen on samsung galaxy r
- black
- android screenshot library is not working in Android 4.4.4
- ASL IMPLEMENTATION
- How to open and read asl-native file
- ASl Provider Null
- How to copy asl-native file in android and run?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-screenshot-library.