# Android issue... rotate image 180 degrees

**URL:** <https://forums.unrealengine.com/t/android-issue-rotate-image-180-degrees/456817>\
**Category:** Mobile\
**Tags:** unreal-engine, question, CPP\
**Created:** [October 11, 2019, 7:56pm UTC](https://forums.unrealengine.com/t/android-issue-rotate-image-180-degrees/456817 "2019-10-11T19:56:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![romfeo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@romfeo](https://forums.unrealengine.com/u/romfeo)\
**Post date:** [October 11, 2019, 7:56pm UTC](https://forums.unrealengine.com/t/android-issue-rotate-image-180-degrees/456817/1 "2019-10-11T19:56:36Z")

</div>

I use the following code from Rama’s plugin to save a CaptureComponent as a PNG file. It works as expected, but in android the image is rotated 180 degrees (it is upside down).  
How could I edit this code so it would rotate the image 180 degrees before saving it to disk, in order for it to be right on Android?

```
bool UsaveJPG::CaptureComponent2D_SaveImage(class USceneCaptureComponent2D* Target, const FString ImagePath, const FLinearColor ClearColour)
{
	// Bad scene capture component! No render target! Stay! Stay! Ok, feed!... wait, where was I?
	if ((Target == nullptr) || (Target->TextureTarget == nullptr))
	{
		return false;
	}

	FRenderTarget* RenderTarget = Target->TextureTarget->GameThread_GetRenderTargetResource();
	if (RenderTarget == nullptr)
	{
		return false;
	}

	TArray<FColor> RawPixels;

	// Format not supported - use PF_B8G8R8A8.
	if (Target->TextureTarget->GetFormat() != PF_B8G8R8A8)
	{
		// TRACEWARN("Format not supported - use PF_B8G8R8A8.");
		return false;
	}

	if (!RenderTarget->ReadPixels(RawPixels))
	{
		return false;
	}

	// Convert to FColor.
	FColor ClearFColour = ClearColour.ToFColor(false); // FIXME - want sRGB or not?

	for (auto& Pixel : RawPixels)
	{
		// Switch Red/Blue changes.
		const uint8 PR = Pixel.R;
		const uint8 PB = Pixel.B;
		Pixel.R = PB;
		Pixel.B = PR;

		// Set alpha based on RGB values of ClearColour.
		Pixel.A = ((Pixel.R == ClearFColour.R) && (Pixel.G == ClearFColour.G) && (Pixel.B == ClearFColour.B)) ? 0 : 255;
	}

	TSharedPtr<IImageWrapper> ImageWrapper = GetImageWrapperByExtention(ImagePath);

	const int32 Width = Target->TextureTarget->SizeX;
	const int32 Height = Target->TextureTarget->SizeY;

	if (ImageWrapper.IsValid() && ImageWrapper->SetRaw(&RawPixels[0], RawPixels.Num() * sizeof(FColor), Width, Height, ERGBFormat::RGBA, 8))
	{
		FFileHelper::SaveArrayToFile(ImageWrapper->GetCompressed(), *ImagePath);
		return true;
	}

	return false;
}
```

---

<div class="post-metadata">

**Author:** ![JJD001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JJD001](https://forums.unrealengine.com/u/JJD001)\
**Post date:** [May 12, 2023, 4:31pm UTC](https://forums.unrealengine.com/t/android-issue-rotate-image-180-degrees/456817/2 "2023-05-12T16:31:52Z")

</div>

hi, did you have resolved this problem? I need help!
