마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

화면 분할 캡쳐 질문드립니다~

0 추천

안녕하세요. Webview에 있는 내용을 분할해서 캡쳐를 뜨고 싶은데 아무리 찾아봐도

통 이미지만 캡쳐하더라구요... 예를들어 길이가 4만이면 1만짜리로 4장을 뜨고 싶은데

                Bitmap captureView = Bitmap.createBitmap(arrWebView.get(i).getMeasuredWidth(), arrWebView.get(i).getMeasuredHeight(), Bitmap.Config.ARGB_8888);    
                Canvas screenShotCanvas = new Canvas(captureView); 

 이 부분을 고치면 될 것 같은데... 높이를 지정해줄수는 없는건가요ㅠ? 

 *참고로 arrWebView는 array형태지만 1개의 webview만 사용하고 있습니다.

 

 

			/******  분할 이미지 저장 *******/
			int startHeight=0;
			int endHeight = 2000;
			int cnt = (arrWebView.get(0).getMeasuredHeight()/ endHeight)+1;
			
			for(int j=0; j<cnt; j++){
				
				Bitmap captureView = Bitmap.createBitmap(arrWebView.get(i).getMeasuredWidth(), arrWebView.get(i).getMeasuredHeight(), Bitmap.Config.ARGB_8888);	
				Canvas screenShotCanvas = new Canvas(captureView);
				Paint paint = new Paint();
				int iHeight = captureView.getHeight();
				screenShotCanvas.drawBitmap(captureView, 0, iHeight, paint);
				arrWebView.get(j).draw(screenShotCanvas);

				if (captureView != null) {
					try {
						String path = Environment.getExternalStorageDirectory().toString();
						OutputStream fOut = null;
						File file = new File(path, "temp");

						if (!file.exists())
							file.mkdirs();

						fOut = new FileOutputStream(path + "/temp/test" + j + ".jpg");
						localFilePath.add(path + "/temp/test" + j + ".jpg");
						captureView.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
						arrDocBitmap.add(captureView);
						arrWebView.get(0).setDrawingCacheEnabled(false);
						
					} catch (FileNotFoundException e) {
						e.printStackTrace();
					}
				}
				
			}
			

 

익명사용자 님이 2016년 7월 7일 질문

1개의 답변

0 추천

Bitmap class의 createBitmap를  이용해서 각 분할한 Bitmap을 만들고 저장하시면 될 듯 합니다.

아래는 4장으로 나누는 예제입니다.

int halfhawidth = captureView.getWidth()/2;

int halfheight = captureView.getHight()/2;

Bitmap b1 = Bitmap.createBitmap(captureView, 0,                    0, halfhawidth ,  halfheight);

Bitmap b2 = Bitmap.createBitmap(captureView, halfhawidth,         0 , halfhawidth,  halfheight);

Bitmap b3 = Bitmap.createBitmap(captureView, 0,           halfheight, halfhawidth,  halfheight);

Bitmap b4 = Bitmap.createBitmap(captureView, halfhawidth, halfheight, halfhawidth  , halfheight );

 

익명사용자 님이 2016년 7월 8일 답변
2016년 7월 8일 수정
Bitmap을 각각 만들어줘야하나요..ㅜㅠ??
비트맵 캡처에 관한 원리를 좀 이해하고 싶은데... 뭐라고 검색해야 알 수 있을까요ㅠ?
...