Skip to content

Commit

Permalink
Added support for kCGImageAlphaNoneSkipFirst
Browse files Browse the repository at this point in the history
Summary:
For kCGImageAlphaNoneSkipFirst type the  FrameType::FORMAT_UNDEFINED == pixelFormat and the returning frame was nil.
Adding support on kCGImageAlphaNoneSkipFirst by
- setting FormatType to RGB32
- adding an if check in order to decide if we are gonna remove the first or the last element.

Reviewed By: foivos-acc, janherling

Differential Revision: D63696938

fbshipit-source-id: 2bb5afa7c759f47f42424af128c9d65172ec895c
  • Loading branch information
pappach authored and facebook-github-bot committed Oct 2, 2024
1 parent 70ec67f commit 3f7f839
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions impl/ocean/media/imageio/IIOObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,10 @@
}

case kCGImageAlphaNoneSkipFirst:
{
break;
}

case kCGImageAlphaNoneSkipLast:
{
if (cgColorSpaceMode == kCGColorSpaceModelRGB && bitsPerPixel == 32)
{
ocean_assert((cgBitmapInfo & kCGBitmapByteOrder32Little) == 0u);

pixelFormat = FrameType::FORMAT_RGB32;
}

Expand Down Expand Up @@ -321,7 +315,14 @@
unsigned int dataPaddingElements = 0u;
if (dataPtr != nullptr && Frame::strideBytes2paddingElements(pixelFormat, (unsigned int)(width), (unsigned int)(bytesPerRow), dataPaddingElements))
{
CV::FrameChannels::removeLastChannel<uint8_t, 4u>((const uint8_t*)(dataPtr), result.data<uint8_t>(), result.width(), result.height(), CV::FrameConverter::CONVERT_NORMAL, dataPaddingElements, result.paddingElements());
if (alphaInfo == kCGImageAlphaNoneSkipLast)
{
CV::FrameChannels::removeLastChannel<uint8_t, 4u>((const uint8_t*)(dataPtr), result.data<uint8_t>(), result.width(), result.height(), CV::FrameConverter::CONVERT_NORMAL, dataPaddingElements, result.paddingElements());
}
else
{
CV::FrameChannels::removeFirstChannel<uint8_t, 4u>((const uint8_t*)(dataPtr), result.data<uint8_t>(), result.width(), result.height(), CV::FrameConverter::CONVERT_NORMAL, dataPaddingElements, result.paddingElements());
}
}
else
{
Expand Down

0 comments on commit 3f7f839

Please sign in to comment.