Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: There's a bug where the output screen turns 90 degrees, Screen has different left and right spacing #20

Conversation

Juhwa-Lee1023
Copy link
Owner

@Juhwa-Lee1023 Juhwa-Lee1023 commented Sep 15, 2022

@LeeSungNo-ian
@jeong-hyeonHwang
@commitcomplete

Outline

Work Contents

  • 실시간 촬영 화면 버그 수정
  • 좌우 패딩값이 다른 버그 수정
  • 카메라에서 불러오는 화면 버그 수정

Trouble Point

1. Image is rotated when retrieving pictures from album.(앨범에서 사진을 불러올 때 이미지가 회전 되어있음.)

  • �Trouble Situation
    • When take a picture with the camera through the UIImagePickerController, the image rotates and enters.(UIImagePickerController를 통해 카메라로 사진을 찍어 불러오면 이미지가 회전되어 들어옴.)

image

  • Trouble Shooting
    • If the image is rotated in UIImage, add a function that rotates normally(UIImage에 이미지가 회전되어 있으면, 정상적으로 회전시켜주는 funtion 추가)
func fixOrientation() -> UIImage {

        // 이미지의 방향이 올바를 경우 수정하지 않는다.
        if ( self.imageOrientation == UIImage.Orientation.up ) {
            return self;
        }

        // 이미지를 변환시키기 위한 함수 선언
        var transform: CGAffineTransform = CGAffineTransform.identity

        // 이미지의 상태에 맞게 이미지를 돌린다.
        if ( self.imageOrientation == UIImage.Orientation.down || self.imageOrientation == UIImage.Orientation.downMirrored ) {
            transform = transform.translatedBy(x: self.size.width, y: self.size.height)
            transform = transform.rotated(by: CGFloat(Double.pi))
        }

        if ( self.imageOrientation == UIImage.Orientation.left || self.imageOrientation == UIImage.Orientation.leftMirrored ) {
            transform = transform.translatedBy(x: self.size.width, y: 0)
            transform = transform.rotated(by: CGFloat(Double.pi / 2.0))
        }

        if ( self.imageOrientation == UIImage.Orientation.right || self.imageOrientation == UIImage.Orientation.rightMirrored ) {
            transform = transform.translatedBy(x: 0, y: self.size.height);
            transform = transform.rotated(by: CGFloat(-Double.pi / 2.0));
        }

        if ( self.imageOrientation == UIImage.Orientation.upMirrored || self.imageOrientation == UIImage.Orientation.downMirrored ) {
            transform = transform.translatedBy(x: self.size.width, y: 0)
            transform = transform.scaledBy(x: -1, y: 1)
        }

        if ( self.imageOrientation == UIImage.Orientation.leftMirrored || self.imageOrientation == UIImage.Orientation.rightMirrored ) {
            transform = transform.translatedBy(x: self.size.height, y: 0);
            transform = transform.scaledBy(x: -1, y: 1);
        }

        // 이미지 변환용 값 선언
        let cgValue: CGContext = CGContext(data: nil, width: Int(self.size.width), height: Int(self.size.height),
                                                      bitsPerComponent: self.cgImage!.bitsPerComponent, bytesPerRow: 0,
                                                      space: self.cgImage!.colorSpace!,
                                                      bitmapInfo: self.cgImage!.bitmapInfo.rawValue)!;
        
        cgValue.concatenate(transform)

        if ( self.imageOrientation == UIImage.Orientation.left ||
             self.imageOrientation == UIImage.Orientation.leftMirrored ||
             self.imageOrientation == UIImage.Orientation.right ||
             self.imageOrientation == UIImage.Orientation.rightMirrored ) {
            cgValue.draw(self.cgImage!, in: CGRect(x: 0,y: 0,width: self.size.height,height: self.size.width))
        } else {
            cgValue.draw(self.cgImage!, in: CGRect(x: 0,y: 0,width: self.size.width,height: self.size.height))
        }

        return UIImage(cgImage: cgValue.makeImage()!)
    }

image

2. The image rotates when the image is processed in real time through the camera.(카메라를 통해 실시간으로 이미지 가공할 때 이미지가 회전됨.)

  • �Trouble Situation
    • The direction of the processed image changes depending on the direction of the device when the app is running.(앱을 실행할 때 디바이스의 방향에 따라 가공된 이미지의 방향이 바뀜.)

image

  • Trouble Shooting
    • The orientation of the image is fixed through AVCapture Video Orientation.portrait without following the state of the device.(이미지의 방향을 디바이스의 상태를 따라가지않고, AVCaptureVideoOrientation.portrait를 통해 고정시킴..)
    //AVCaptureDevice.default(for: AVMediaType.video)
AVCaptureDevice.default(for: AVMediaType.video)

image

3. The left and right margins of the main camera view are different.(메인 카메라 뷰의 좌우 여백이 다름.)

  • �Trouble Situation

    • Camera view does not follow the frame of cameraview.(cameraview의 frame을 카메라뷰가 따라가지않음.)
  • Trouble Shooting

    • cameraviewframe이 아니라 bounds를 따라가도록 변경(Change to follow the bounds, not the frame of 'cameraview'.)
    //previewLayer?.frame = cameraView.frame
previewLayer?.frame = cameraView.bounds

@Juhwa-Lee1023 Juhwa-Lee1023 added the bug Something isn't working label Sep 15, 2022
@Juhwa-Lee1023 Juhwa-Lee1023 self-assigned this Sep 15, 2022
@LeeSungNo-ian
Copy link

LeeSungNo-ian commented Sep 15, 2022

고생하셨습니다 코인!
작성한 리뷰 읽고 답변 주세요!

Copy link

@jeong-hyeonHwang jeong-hyeonHwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스도쿠!!! 너무 좋아요!!!

@Juhwa-Lee1023 Juhwa-Lee1023 merged commit f88e400 into main Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: There's a bug where the output screen turns 90 degrees, Screen has different left and right spacing
4 participants