Skip to content

Commit

Permalink
Convert imagepipeline-base/src/main/java/com/facebook/imageutils
Browse files Browse the repository at this point in the history
Reviewed By: oprisnik

Differential Revision: D59222625

fbshipit-source-id: 025e0c4e5a6d0a63864ed8431096e22ed81aa6d4
  • Loading branch information
steelrooter authored and facebook-github-bot committed Jul 1, 2024
1 parent 14b630b commit 572f320
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 73 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.imagepipeline.transcoder

import com.facebook.imageformat.ImageFormat

interface ImageTranscoderFactory {

/**
* Creates an [ImageTranscoder] that enables or disables resizing depending on
* `isResizingEnabled`. It can return null if the [ImageFormat] is not supported by this
* [ImageTranscoder].
*
* Note that if JPEG images are not supported, we will fallback to our native [ImageTranscoder]
* implementation.
*
* @param imageFormat the [ImageFormat] of the input images.
* @param isResizingEnabled true if resizing is allowed.
* @return The [ImageTranscoder] or null if the image format is not supported.
*/
fun createImageTranscoder(imageFormat: ImageFormat, isResizingEnabled: Boolean): ImageTranscoder?
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.imagepipeline.transcoder

import androidx.annotation.IntDef

/** Status used by [ImageTranscodeResult] to supply additional information. */
@Retention(AnnotationRetention.SOURCE)
@IntDef(
TranscodeStatus.TRANSCODING_SUCCESS,
TranscodeStatus.TRANSCODING_NO_RESIZING,
TranscodeStatus.TRANSCODING_ERROR,
)
annotation class TranscodeStatus {
companion object {
/** Status flag to show that the image was transcoded successfully. */
/** Status flag to show that the image was transcoded successfully. */
const val TRANSCODING_SUCCESS: Int = 0

/** Status flag to show that the input image transcoded successfully without resizing. */
/** Status flag to show that the input image transcoded successfully without resizing. */
const val TRANSCODING_NO_RESIZING: Int = 1

/** Status flag to show that an error occurred while transcoding the image. */
/** Status flag to show that an error occurred while transcoding the image. */
const val TRANSCODING_ERROR: Int = 2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import java.io.InputStream
/** Util for processing Stream. */
internal object StreamProcessor {
/**
* Consumes up to 4 bytes and returns them as int (taking into account endianess). Throws
* Consumes up to 4 bytes and returns them as int (taking into account endianness). Throws
* exception if specified number of bytes cannot be consumed.
*
* @param stream the input stream to read bytes from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MultiImageTranscoderFactory(
override fun createImageTranscoder(
imageFormat: ImageFormat,
isResizingEnabled: Boolean
): ImageTranscoder? {
): ImageTranscoder {
// Use custom ImageTranscoder, if any
var imageTranscoder = getCustomImageTranscoder(imageFormat, isResizingEnabled)
// Use ImageTranscoder based on type passed, if any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.facebook.infer.annotation.Nullsafe;

/** Factory class to create an {@link SimpleImageTranscoder} */
@Nullsafe(Nullsafe.Mode.STRICT)
@Nullsafe(Nullsafe.Mode.LOCAL)
public class SimpleImageTranscoderFactory implements ImageTranscoderFactory {

private final int mMaxBitmapSize;
Expand Down

0 comments on commit 572f320

Please sign in to comment.