MCPcopy Create free account
hub / github.com/buggins/coolreader / checkImage

Method checkImage

android/jni/docview.cpp:1390–1426  ·  view source on GitHub ↗

checks whether point belongs to image: if found, returns true, and _currentImage is set to image

Source from the content-addressed store, hash-verified

1388
1389// checks whether point belongs to image: if found, returns true, and _currentImage is set to image
1390bool DocViewNative::checkImage(int x, int y, int bufWidth, int bufHeight, int &dx, int &dy, bool & needRotate)
1391{
1392 _currentImage = _docview->getImageByPoint(lvPoint(x, y));
1393 if (_currentImage.isNull())
1394 return false;
1395 dx = _currentImage->GetWidth();
1396 dy = _currentImage->GetHeight();
1397 if (dx < 8 && dy < 8) {
1398 _currentImage.Clear();
1399 return JNI_FALSE;
1400 }
1401 needRotate = false;
1402 if (bufWidth <= bufHeight) {
1403 // screen == portrait
1404 needRotate = 8 * dx > 10 * dy;
1405 } else {
1406 // screen == landscape
1407 needRotate = 10 * dx < 8 * dy;
1408 }
1409 int scale = 1;
1410 if (dx * dy > MAX_IMAGE_BUF_SIZE) {
1411 scale = dx * dy / MAX_IMAGE_BUF_SIZE;
1412 dx /= scale;
1413 dy /= scale;
1414 }
1415 LVColorDrawBuf * buf = new LVColorDrawBuf(dx, dy);
1416 buf->Clear(0xFF000000); // transparent
1417 buf->Draw(_currentImage, 0, 0, dx, dy, false);
1418 if (needRotate) {
1419 int c = dx;
1420 dx = dy;
1421 dy = c;
1422 buf->Rotate(CR_ROTATE_ANGLE_90);
1423 }
1424 _currentImage = LVCreateDrawBufImageSource(buf, true);
1425 return true;
1426}
1427
1428// draws current image to buffer (scaled, panned)
1429bool DocViewNative::drawImage(LVDrawBuf * buf, int x, int y, int dx, int dy)

Calls 9

lvPointClass · 0.85
getImageByPointMethod · 0.80
isNullMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45
ClearMethod · 0.45
DrawMethod · 0.45
RotateMethod · 0.45

Tested by

no test coverage detected