<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>maro_park.log</title>
        <link>https://velog.io/</link>
        <description>Software Developer</description>
        <lastBuildDate>Tue, 27 Dec 2022 05:14:53 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>maro_park.log</title>
            <url>https://velog.velcdn.com/images/maro_park/profile/5ef29866-456d-43ba-aa0d-668d81545c13/social_profile.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. maro_park.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/maro_park" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[Kotlin&Android] 두 LocalDate 간의 차이 일수 계산]]></title>
            <link>https://velog.io/@maro_park/KotlinAndroid-%EB%91%90-LocalDate-%EA%B0%84%EC%9D%98-%EC%B0%A8%EC%9D%B4-%EC%9D%BC%EC%88%98-%EA%B3%84%EC%82%B0</link>
            <guid>https://velog.io/@maro_park/KotlinAndroid-%EB%91%90-LocalDate-%EA%B0%84%EC%9D%98-%EC%B0%A8%EC%9D%B4-%EC%9D%BC%EC%88%98-%EA%B3%84%EC%82%B0</guid>
            <pubDate>Tue, 27 Dec 2022 05:14:53 GMT</pubDate>
            <description><![CDATA[<ol>
<li>어플 개발도중 두 LocalDate 데이터 간의 차이를 구하는 법이 필요했다.</li>
<li>java.time.tempral.ChronoUnit 이라는 클래스에 두 LocalDate 간의 차이 일수를 계산해주는 함수를 발견</li>
<li>함수안에 어떤 값을 순서로 넣어주는 거에 따라 음수가 나와 내가 필요한 기능은 단순 두 LocalDate 간의 차이 일수가 필요해서 절대값을 구하는 abs 함수를 사용하였다.</li>
</ol>
<blockquote>
<p><img src="https://velog.velcdn.com/images/maro_park/post/e4088ee4-e998-42ca-aff5-1dd6df9da906/image.png" alt=""></p>
</blockquote>
<p>밑에 사진은 간단한 테스트 코드</p>
<blockquote>
<p><img src="https://velog.velcdn.com/images/maro_park/post/ec03d362-2b1e-40af-97cb-10d465deb22b/image.png" alt=""></p>
</blockquote>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Kotlin] Bitmap]]></title>
            <link>https://velog.io/@maro_park/Kotlin-Bitmap</link>
            <guid>https://velog.io/@maro_park/Kotlin-Bitmap</guid>
            <pubDate>Tue, 13 Dec 2022 06:24:24 GMT</pubDate>
            <description><![CDATA[<p>Android CameraX 와 TensorFlow Lite 사용하면서 ...</p>
<hr>
<h2 id="bytearray---bitmap">ByteArray -&gt; Bitmap</h2>
<pre><code>fun ByteArray.toBitmap(): Bitmap? {
    return BitmapFactory.decodeByteArray(this, 0, this.size)
}</code></pre><h2 id="androidmediaimage---bitmap">android.media.image -&gt; Bitmap</h2>
<pre><code>fun Image.toBitmap(): Bitmap {
            val yBuffer = planes[0].buffer // Y
            val vuBuffer = planes[2].buffer // VU

            val ySize = yBuffer.remaining()
            val vuSize = vuBuffer.remaining()

            val nv21 = ByteArray(ySize + vuSize)

            yBuffer.get(nv21, 0, ySize)
            vuBuffer.get(nv21, ySize, vuSize)

            val yuvImage = YuvImage(nv21, ImageFormat.NV21, this.width, this.height, null)
            val out = ByteArrayOutputStream()
            yuvImage.compressToJpeg(Rect(0, 0, yuvImage.width, yuvImage.height), 50, out)
            val imageBytes = out.toByteArray()
            return BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
        }</code></pre><h2 id="rotate-bitmap">Rotate Bitmap</h2>
<pre><code>val matrix = Matrix().apply {
            postRotate(90F)
        }

val createBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, false)</code></pre><h2 id="camerapreview-안에-있는-뷰-크기만큼-자르는-방법">CameraPreview 안에 있는 뷰 크기만큼 자르는 방법</h2>
<p><img src="https://velog.velcdn.com/images/maro_park/post/d0a6ba7d-dcaf-4100-b4ab-0199700581d9/image.png" alt=""></p>
<pre><code>private fun cropImage(bitmap: Bitmap, cameraPreview: View, innerView: View): ByteArray {

        val heightOriginal = cameraPreview.height // preview height
        val widthOriginal = cameraPreview.width // preview width
        val heightFrame = innerView.height
        val widthFrame = innerView.width


        val heightReal = bitmap.height
        val widthReal = bitmap.width
        val widthFinal = widthFrame * widthReal / widthOriginal
        val heightFinal = heightFrame * heightReal / heightOriginal

        val maxX = cameraPreview.width - innerView.width
        val maxY = cameraPreview.height - innerView.height

        val leftFrame = if (innerView.x.toInt() &lt; 0) {
            0
        } else if (innerView.x.toInt() &gt; maxX) {
            maxX
        } else {
            innerView.x.toInt()
        }

        val topFrame = if (innerView.y.toInt() &lt; 0) {
            0
        } else if (innerView.y.toInt() &gt; maxY) {
            maxY
        } else {
            innerView.y.toInt()
        }


        val bitmapFinal = Bitmap.createBitmap(
            bitmap,
            leftFrame, topFrame, widthFinal, heightFinal
        )
        val stream = ByteArrayOutputStream()
        bitmapFinal.compress(
            Bitmap.CompressFormat.JPEG,
            100,
            stream
        ) //100 is the best quality possible
        return stream.toByteArray()
    }</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[Android] ViewBinding 설정]]></title>
            <link>https://velog.io/@maro_park/Android-ViewBinding-%EC%84%A4%EC%A0%95</link>
            <guid>https://velog.io/@maro_park/Android-ViewBinding-%EC%84%A4%EC%A0%95</guid>
            <pubDate>Thu, 08 Dec 2022 00:43:38 GMT</pubDate>
            <description><![CDATA[<h2 id="buildgradle-module">build.gradle (Module)</h2>
<blockquote>
<pre><code>android {
    buildFeatures {
        viewBinding true
    }
}</code></pre></blockquote>
<pre><code>
## Example Code
&gt;![](https://velog.velcdn.com/images/maro_park/post/f2e14709-5b86-40dd-a7b5-0905f88eaeca/image.png)
&gt; 바인딩한 해당 액티비티 or 프래그먼트의 자식 뷰들의 아이디는 카멜 표기법으로 변경되어 binding 안에서 찾을 수 있다.

## Why?
&gt; 1. Null 로 부터 안전하다.
2. 오직 현재 레이아웃의 참조 아이디만 가져옴
3. 코틀린 &amp; 자바 모두 지원
4. 필요향 코드의 양이 적음


## 주의사항
&gt; Gradle Version 3.6 이상 4.0미만</code></pre><p>android {
    viewBinding {
        enabled = true
    }
}
```</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[git commit message convention]]></title>
            <link>https://velog.io/@maro_park/git-commit-message-convention</link>
            <guid>https://velog.io/@maro_park/git-commit-message-convention</guid>
            <pubDate>Mon, 05 Dec 2022 07:13:38 GMT</pubDate>
            <description><![CDATA[<hr>
<h2 id="gitmoji">gitmoji</h2>
<p>🎨 Improve structure / format of the codes.
⚡️ Improve performance.
🔥 Remove code or files.
🐛 Fix a bug.
🚑️ Critical hotfix.
✨ Introduce new features.
📝 Add or update documentation.
🚀 Deploy stuff.
💄 Add or Update the UI and style files.
🎉 Begin a Project
✅ Add, update, or pass tests.
🔒️ Fix security issues.
🔐 Add or update secrets.
🔖 Relase / Version tags.
🚨 Fix compiler / linter warning.
🚧 Work in progress.
💚 Fix CI build.
⬇️ Downgrade dependencies.
⬆️ Upgrade dependencies.
📌 Pin dependencies to specific versions.
👷 Add or update CI build system.
📈 Add or update analystics or track code.
♻️ Refactor code.
➕ Add a dependency.
➖ remove a dependency.
🔧 Add or update configuration files.
🔨 Add or update development scripts.
🌐 Internationalization and localization.</p>
<hr>
<h2 id="commit-message-convention">Commit Message Convention</h2>
<blockquote>
<p>type : subject </p>
<p>body</p>
<p>footer</p>
</blockquote>
<hr>
<h2 id="commit-type">Commit Type</h2>
<p>feat : ✨
fix : 🐛
docs : 📝
style : 💄
refactor : ♻️
test : ✅
chore : 해당 커밋 타입의 어울리는 이모지 사용</p>
<hr>
<h2 id="예시">예시</h2>
<blockquote>
<p>✨ : Implement login API</p>
<p> Client 에서 POST 방식으로 아이디와 패스워드를 Json Object 형식으로 전송하면 해당 데이터를 받아 member TABLE 에서 데이터 확인 후 성공시 200 코드와 JWT 토큰을 발급 이외의 경우 상황에 맞는 HTTP response status code를 리턴한다.</p>
<p>JWT, SPRING SECURITY 관련 커밋
Ref: #653d7e9d, #fb96c6fe</p>
</blockquote>
<h4 id="작성해봤는데-이렇게-작성하는게-맞는지"><del>작성해봤는데.. 이렇게 작성하는게 맞는지..</del></h4>
<hr>
<h2 id="reference">Reference</h2>
<p><a href="https://gitmoji.dev/">gitmoji.dev</a>
<a href="https://doublesprogramming.tistory.com/256">Git - 커밋 메시지 컨벤션</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[코틀린 유용한 함수]]></title>
            <link>https://velog.io/@maro_park/%EC%BD%94%ED%8B%80%EB%A6%B0-%EC%9C%A0%EC%9A%A9%ED%95%9C-%ED%95%A8%EC%88%98</link>
            <guid>https://velog.io/@maro_park/%EC%BD%94%ED%8B%80%EB%A6%B0-%EC%9C%A0%EC%9A%A9%ED%95%9C-%ED%95%A8%EC%88%98</guid>
            <pubDate>Mon, 05 Dec 2022 01:37:07 GMT</pubDate>
            <description><![CDATA[<hr>
<h3 id="flatten">flatten</h3>
<h4 id="returns-a-single-list-of-all-elements-from-all-arrays-in-the-given-array">Returns a single list of all elements from all arrays in the given array.</h4>
<blockquote>
<p><img src="https://velog.velcdn.com/images/maro_park/post/ee4c6347-d687-4031-9f0f-ab422fb21414/image.png" alt=""></p>
<blockquote>
<p>여러 배열들로 이루어진 배열의 원소들을 한배열에 합쳐준다고 생각하면 된다.</p>
</blockquote>
</blockquote>
<hr>
<h3 id="groupingby-eachcount">groupingBy, eachCount</h3>
<h4 id="creates-a-grouping-source-from-an-array-to-be-used-later-with-one-of-group-and-fold-operations-using-the-specified-keyselector-function-to-extract-a-key-from-each-element">Creates a Grouping source from an array to be used later with one of group-and-fold operations using the specified keySelector function to extract a key from each element.</h4>
<blockquote>
<p><img src="https://velog.velcdn.com/images/maro_park/post/569c3578-a5fb-43f8-8e96-7e4891d614d5/image.png" alt=""></p>
<blockquote>
<p>SQL 문 작성시 이용하는 GROUP BY 와 Count(*)를 생각하면 된다.</p>
</blockquote>
</blockquote>
]]></description>
        </item>
    </channel>
</rss>