Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.RenderMode

class MainActivity: FlutterActivity() {
override fun getRenderMode(): RenderMode = RenderMode.texture
override fun getRenderMode(): RenderMode = RenderMode.surface
}
7 changes: 6 additions & 1 deletion example/lib/pages_with_tiled_images/image_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,14 @@ class DocumentPageTileImagePainter implements ImagePainter {
Future<void> _paintImage(PageRegionRenderRequest request, TileIndex tileIndex) async {
final imageCompleter = Completer<ui.Image>();
final index = (tileIndex.col + tileIndex.row) % _imageAssets.length;
final imageStream = AssetImage(_imageAssets[index]).resolve(
final imageStream = ResizeImage(
AssetImage(_imageAssets[index]),
width: 1024,
height: 768,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost certainly still way too big, but should be better than the current implementation.

Ideally these sizes would be as close as possible to the resolution you will actually display the image at.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also probably only want to specify one dimension or use ResizeImagePolicy.fit (which is not the default)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I wasn't sure what values to use so I just chose that. When I tried it out, I got extra vertical whitespace.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if you use fit it will use that as a bounding box - if you specify one dimension it'll automatically scale the other dimension to preserve the aspect ratio.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I switched it to the fit policy.

).resolve(
const ImageConfiguration(),
);

final listener = ImageStreamListener((ImageInfo imageInfo, bool synchronousCall) {
imageCompleter.complete(imageInfo.image);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PageListImagesInspectorDemo extends StatefulWidget {
}

class _PageListImagesInspectorDemoState extends State<PageListImagesInspectorDemo> with TickerProviderStateMixin {
static final _naturalPageSize = const Size(8.5, 11) * 72;
static final _naturalPageSize = const Size(8.5, 11) * 14.4;

final _pageViewportKey = GlobalKey();
late PageListViewportController _viewportController;
Expand Down