Tip/Windows2023. 9. 22. 01:02

 C#을 배우면서 간단한 이미지 뷰어를 만들어 보았다.

기능:

 Drag & Drop 

R / L  키로 이미지 회전

Left, Right 화살표 키로 이미지 전환 (같은 폴더내)

Up 화살표키: 첫번째 이미지 (알파벳 순)

Down 화살표키: 마지막 이미지 (알파벳 순)

 

전체 소스코드:

https://github.com/chobocho/choboImageViewer

 

GitHub - chobocho/choboImageViewer: Simple image view by c#

Simple image view by c#. Contribute to chobocho/choboImageViewer development by creating an account on GitHub.

github.com

 

실행파일:

- 경고: 사용시 발생하는 어떤 이슈도 책임 지지 않습니다.

ImageViewer_32bit.zip
0.16MB

구현 관련

1. 메모리릭 이슈

-  PictureBox 에 이미지를 바꿀 때에는 반드시, dispose() 메서드 호출 후 null을 대입해야 한다.

            if (pictureBox.BackgroundImage != null)
            {
                pictureBox.BackgroundImage.Dispose();
                pictureBox.BackgroundImage = null;
            }

2. 파일을 읽어서, 파일이 위치한 폴더의 모든 이미지 파일 읽기. (Chat GPT 형님의 도움을 받았다)

    public void setFileName(string? filename)
    {
        if (filename == null || !File.Exists(filename)) return;
        string[] imageExtensions = { ".jpg", ".jpeg", ".png", ".gif", ".bmp", "ico" }; 
        
        // 이 부분 입니다.
        _filesList = Directory.GetFiles(Path.GetDirectoryName(@filename) ?? string.Empty)
            .Where(file => imageExtensions.Contains(Path.GetExtension(file).ToLower()))
            .Select(Path.GetFullPath).ToArray();

        Array.Sort(_filesList);
        _index = Array.IndexOf(_filesList, filename);
    }

3. 이미지 회전

- 여기서는 dispose() 메서드 호출 하지 않는다. 호출 하면 이미지 객체가 삭제된다.

- 마지막에 pictureBox.Refresh() 메소드를 꼭 호출해 주어야 회전한 이미지로 업데이트 된다.

        void rotateImage(System.Drawing.RotateFlipType angle)
        {
            var LoadedImage = pictureBox.BackgroundImage;
            LoadedImage.RotateFlip(angle);

            pictureBox.BackgroundImage = LoadedImage;

            var width = LoadedImage.Width > minimumSize ? LoadedImage.Width : minimumSize;
            width = LoadedImage.Width > maximumSize ? maximumSize : width;

            var height = LoadedImage.Height > minimumSize ? LoadedImage.Height : minimumSize;
            height = LoadedImage.Height > maximumSize ? maximumSize : height;

            this.Width = width;
            this.Height = height;

            pictureBox.Refresh();
        }

'Tip > Windows' 카테고리의 다른 글

[ScanSnap] 스캔스냅 사용팁  (0) 2021.08.09
[Excel] 엑셀 수식 자동 계산이 안 될 때  (0) 2021.08.07
검색 잘 하기  (0) 2021.08.07
Posted by chobocho
Tip/Android2023. 8. 30. 23:03

Hexa Game 앱은 어떠한 개인 정보도 수집하지 않습니다.

Hexa Game does not collect any personal information.

Posted by chobocho
Tip/Android2023. 8. 30. 01:30

직각 삼각형 대각선 길이 구하기 앱은 어떠한 개인 정보도 수집하지 않습니다.

Triangle application does not collect any personal information.

Posted by chobocho
Tip/Android2023. 8. 30. 00:47

제비뽑기 앱은 어떠한 개인 정보도 수집하지 않습니다.

ChooseOne application does not collect any personal information.

Posted by chobocho
Tip/Android2023. 8. 30. 00:25

솔리테어 게임은 어떠한 개인 정보도 수집하지 않습니다.

Solitaire Card Game does not collect any personal information.

 

Posted by chobocho
Tip/Android2023. 8. 22. 23:34

AndroidManifest.xml에 아래와 같이 권한을 추가 한다

    <uses-feature
        android:name="android.hardware.telephony"
        android:required="false" />

    <uses-feature android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />

 MainActivity안에 아래와 같이 버튼에 이벤트를 연결한다.

    private fun init() {
        val callButton : Button = findViewById(R.id.callButton)
        callButton.setOnClickListener( View.OnClickListener { _ -> runCall() })
    }

    private fun runCall() {
        val intent = Intent(Intent.ACTION_CALL, Uri.parse("tel:01234561492"))
        val status = ActivityCompat.checkSelfPermission(this, 
            android.Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED
        if (status) {
            startActivity(intent)
        } else {
            Log.i("TAG", "Unable to launch call");
            ActivityCompat.requestPermissions(this, 
                arrayOf<String>(android.Manifest.permission.CALL_PHONE), CALL_REQUEST)
        }
    }

아래와 같이 onRequestPermissionsReseult()를 오버라이딩 해주면, 권한 컨펌 즉시 콜이 걸리게 된다.

    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        when (requestCode) {
            CALL_REQUEST -> {
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    Toast.makeText(this, "통화가 가능 합니다", Toast.LENGTH_LONG).show()
                    runCall()
                } else {
                    Toast.makeText(this, "통화가 거절 되었습니다", Toast.LENGTH_LONG).show()
                }
            }
        }
    }
Posted by chobocho
Tip/Android2023. 1. 26. 00:26

 

An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'com.android.application']
	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.exceptionOccurred(DefaultPluginRequestApplicator.java:207)
	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:189)

//...

Caused by: com.android.builder.errors.EvalIssueException: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
  - changing the IDE settings.
  - changing the JAVA_HOME environment variable.
  - changing `org.gradle.java.home` in `gradle.properties`.
	at com.android.builder.errors.IssueReporter.reportError(IssueReporter.kt:109)
	at com.android.builder.errors.IssueReporter.reportError$default(IssueReporter.kt:105)
	at com.android.builder.errors.IssueReporter.reportError(IssueReporter.kt)

아래와 같이 Setting에서 Gradle JDK를 Java 11로 변경해주면 된다.

Posted by chobocho
Tip/Windows2021. 8. 9. 02:30

* 스캔스냅 으로 대량 자료 스캔시, 자동 회전이나 빈 페이지 삭제 기능이, 오히려 불편함을 초래 할 때가 있다.

해당 기능을 off 하려면 아래와 같다

'Tip > Windows' 카테고리의 다른 글

[C#] PictureBox 로 간단한 이미지 뷰어 만들기  (0) 2023.09.22
[Excel] 엑셀 수식 자동 계산이 안 될 때  (0) 2021.08.07
검색 잘 하기  (0) 2021.08.07
Posted by chobocho
Tip/Windows2021. 8. 7. 00:35

파일 > 옵션 > 수식에서 아래와 같이 

통합 문서 계산 > 자동  을 선택하며 된다.

'Tip > Windows' 카테고리의 다른 글

[ScanSnap] 스캔스냅 사용팁  (0) 2021.08.09
검색 잘 하기  (0) 2021.08.07
Xbox 4세대 컨트롤러 사용기  (0) 2021.04.15
Posted by chobocho
Tip/Windows2021. 8. 7. 00:31

1. 검색은 구글에서 하는 이다.

 

2. 핵심 검색어를 포함해라.

* 반드시 문장으로 써야 할 필요는 없다. 핵심 키워드만 나열해도 된다.

3. 특정 site 자료만 검색하는 방법

* 검색어 site:주소   와 같이 써주면 된다.

4. 내가 찾는 단어들이 반드시 포함된 사이트만 검색하기

  • 검색어 사이에 '+' 써주면 된다.
  • 예: 안드로이드, 테트리스, 만들기 3 단어가 반드시 포함된 사이트를 찾기

'Tip > Windows' 카테고리의 다른 글

[Excel] 엑셀 수식 자동 계산이 안 될 때  (0) 2021.08.07
Xbox 4세대 컨트롤러 사용기  (0) 2021.04.15
Batch file 템플릿  (2) 2020.12.22
Posted by chobocho