Skip to content

Commit

Permalink
Update comment
Browse files Browse the repository at this point in the history
Co-authored-by: Tobi <TobiGr@users.noreply.github.com>
  • Loading branch information
Thompson3142 and TobiGr committed Oct 27, 2024
1 parent 05a87da commit ba1e9c8
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void generateDataFrom(final Frameset frameset, final UUID updateRequestI
// Get the bounds where the frame is found
final int[] bounds = frameset.getFrameBoundsAt(currentPosMs);
generatedDataForUrl.put(currentPosMs,
createBitmapSupplier(srcBitMap, bounds, frameset));
createBitmapSupplier(srcBitMap, bounds, frameset));

currentPosMs += frameset.getDurationPerFrame();
pos++;
Expand Down Expand Up @@ -168,6 +168,18 @@ private Supplier<Bitmap> createBitmapSupplier(final Bitmap srcBitMap,
return null;
}

// Under some rare circumstances the YouTube API returns slightly too small storyboards,
// (or not the matching frame width/height)
// This would lead to createBitmap cutting out a bitmap that is out of bounds,
// so we need to adjust the bounds accordingly
if (srcBitMap.getWidth() < bounds[1] + frameset.getFrameWidth()) {
bounds[1] = srcBitMap.getWidth() - frameset.getFrameWidth();
}

if (srcBitMap.getHeight() < bounds[2] + frameset.getFrameHeight()) {
bounds[2] = srcBitMap.getHeight() - frameset.getFrameHeight();
}

// Cut out the corresponding bitmap form the "srcBitMap"
final Bitmap cutOutBitmap = Bitmap.createBitmap(srcBitMap, bounds[1], bounds[2],
frameset.getFrameWidth(), frameset.getFrameHeight());
Expand Down

0 comments on commit ba1e9c8

Please sign in to comment.