readium / SDKLauncher-iOS

A small iOS application to serve as a launcher/testbed for the Readium SDK.
BSD 3-Clause "New" or "Revised" License
71 stars 47 forks source link

Reference Cover image From Epub #96

Closed sage-IT closed 6 years ago

sage-IT commented 6 years ago

This issue is a Question

Hey guys so I've been working on and Off on the IOS SDK and have made a bit of progress with creating a Cell Collection View and Displaying the Epub title as a label in each cell. Now I want to get the cover image or first page as an UIImage. Is this referenced as a one of the path components? If not what would be the best solution.

Related issue(s) and/or pull request(s)

NA

Expected Behaviour

UIImage View displays image of specified ePub

Observed behaviour

I can add an image to a project and just display that but

Steps to reproduce

Test file(s)

My project files for the SDKLauncher are here on google drive

Product

danielweck commented 6 years ago

Follow-up to: https://github.com/readium/SDKLauncher-iOS/issues/87

danielweck commented 6 years ago

You can query the cover-image "manifest item": https://github.com/readium/readium-sdk/blob/80a71fedf03f6f11ba7f900daf0ac67675388908/ePub3/ePub/manifest.h#L76 https://github.com/readium/readium-sdk/blob/80a71fedf03f6f11ba7f900daf0ac67675388908/ePub3/ePub/manifest.cpp#L33

danielweck commented 6 years ago

...and there's already a function for this: https://github.com/readium/readium-sdk/blob/80a71fedf03f6f11ba7f900daf0ac67675388908/ePub3/ePub/package.cpp#L1682 shared_ptr<ManifestItem> Package::CoverManifestItem()

danielweck commented 6 years ago

Then, you can read the image resource into a buffer, via:

https://github.com/readium/readium-sdk/blob/80a71fedf03f6f11ba7f900daf0ac67675388908/ePub3/ePub/package.cpp#L1360

...and:

https://github.com/readium/readium-sdk/blob/80a71fedf03f6f11ba7f900daf0ac67675388908/ePub3/utilities/byte_stream.h#L137

rohitvishwakarma-sf commented 2 years ago

@sage-IT were you able to get cover image ?

@danielweck the link you mentioned have code in cpp. How can I use it in swift ?

danielweck commented 2 years ago

Hello @rohitvishwakarma-sf you probably need to look into https://github.com/readium/swift-toolkit