Skip to content

Commit 99ffb14

Browse files
committed
1.305 업데이트
- Snipping OCR - 앱 실행시 언어가 항상 English로 설정되어 잇는 문제 수정 - Snipping OCR - HSV / RGB 로 추출시 사용할 수 없는 문제 수정 - Gemini API - 횟수당 사용하는 토큰 수 최적화 - DeepL API - 중국어 번역이 안 되는 문제 수정
1 parent e092c3f commit 99ffb14

File tree

9 files changed

+39
-37
lines changed

9 files changed

+39
-37
lines changed

MORT/Form1.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3233,7 +3233,9 @@ private void ChangeMainOcrLangauge(OcrLanguageType ocrLanguageType)
32333233
if(code != "other")
32343234
{
32353235
SetTransLangugage(code);
3236-
}
3236+
}
3237+
3238+
_currentOcrLanguage = ocrLanguageType;
32373239
}
32383240

32393241

MORT/FormOption.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private void SetValueToUIValue()
169169
{
170170
_currentOcrLanguage = MySettingManager.OcrLanguageType;
171171
}
172-
int index = _ocrLanguages.IndexOf(_currentOcrLanguage);
172+
int index = _ocrLanguages.IndexOf(_currentOcrLanguage);
173173
cbOneOcrLanguage.SelectedIndex = index;
174174

175175
//색 관련 처리

MORT/Logger/LoggerForm.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public class CountChangedEventArgs : EventArgs
138138
// 로그 추가 (static wrapper)
139139
public static void AddLog(string message)
140140
{
141+
return;
141142
if(message == null) throw new ArgumentNullException(nameof(message));
142143
_instance.AddLogInternal(message);
143144
}
@@ -158,12 +159,14 @@ private void AddLogInternal(string message)
158159
// OCR/Trans 카운트 증가 - static wrapper
159160
public static void IncrementOcr()
160161
{
162+
return;
161163
_instance.IncrementOcrInternal();
162164
}
163165

164166
// Trans 카운트 증가 - static wrapper
165167
public static void IncrementTrans()
166168
{
169+
return;
167170
_instance.IncrementTransInternal();
168171
}
169172

MORT/OcrApi/OneOcr/OneOcr.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,14 @@ private string PtrToManagedString(IntPtr ptr)
461461
}
462462
else if(channel == 3)
463463
{
464-
// 입력이 RGB 순서라 가정. (프로젝트 기존 코드와 동일하게 처리)
464+
// BGR 이라는 가정
465465
buffer[dst++] = byteData[src++]; // R or B depending on input format
466466
buffer[dst++] = byteData[src++];
467467
buffer[dst++] = byteData[src++];
468468
}
469469
else if(channel == 4)
470470
{
471-
// RGBA -> RGB (알파 무시)
471+
// BGRA 순서라 가정
472472
buffer[dst++] = byteData[src++]; // R or B depending on input format
473473
buffer[dst++] = byteData[src++];
474474
buffer[dst++] = byteData[src++];
@@ -525,7 +525,7 @@ public async ValueTask<Line[]> ConvertToTextAsync(byte[] byteData, int channel,
525525
// 네이티브 라이브러리에 맞춘 Img 구조체 생성
526526
Img formattedImage = new Img
527527
{
528-
t = channel,
528+
t = 1,
529529
col = cols,
530530
row = rows,
531531
_unk = 0,

MORT/Properties/Settings.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MORT/Properties/Settings.settings

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<Profiles />
44
<Settings>
55
<Setting Name="MORT_VERSION" Type="System.String" Scope="Application">
6-
<Value Profile="(Default)">1.304V - Test2</Value>
6+
<Value Profile="(Default)">1.305V</Value>
77
</Setting>
88
<Setting Name="LAYER_TEXT" Type="System.String" Scope="Application">
99
<Value Profile="(Default)">MORT {0}
1010
레이어 번역창</Value>
1111
</Setting>
1212
<Setting Name="MORT_VERSION_VALUE" Type="System.Int32" Scope="Application">
13-
<Value Profile="(Default)">1304</Value>
13+
<Value Profile="(Default)">1305</Value>
1414
</Setting>
1515
<Setting Name="TOOLTIP_LIST" Type="System.String" Scope="Application">
1616
<Value Profile="(Default)">MORT를 처음 쓰시면 그 외-&gt; MORT 사용법을 확인해 주세요,
@@ -45,7 +45,7 @@ OCR 영역을 빠르게 추가하고 싶을 땐 빠른 OCR 영역을 사용하
4545
구글 OCR의 사용량은 실제 사용량과 다를 수 있습니다. 수시로 구글 콘솔에서 확인하셔야 합니다</Value>
4646
</Setting>
4747
<Setting Name="MORT_RELEASE" Type="System.String" Scope="Application">
48-
<Value Profile="(Default)">2025 12 12</Value>
48+
<Value Profile="(Default)">2025 12 14</Value>
4949
</Setting>
5050
<Setting Name="BASIC_TEXT" Type="System.String" Scope="Application">
5151
<Value Profile="(Default)">Monkeyhead's OCR Realtime TransLate {0}

MORT/Service/ProcessTranslateService/ProcessTranslateService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ private async Task DoTrans(OcrMethodType ocrMethodType)
749749
var task = _oneOcr.ConvertToTextAsync(imgDataList[j].data, imgDataList[j].channels, imgDataList[j].x, imgDataList[j].y, imgDataList[j].Clear).ConfigureAwait(false);
750750

751751
var result = task.GetAwaiter().GetResult();
752+
752753
if(result == null)
753754
{
754755
// 백그라운드에서 UI를 직접 호출하지 않음. UI 스레드에서 알리고 종료 트리거.

MORT/TransAPI/GeminiTranslatorAPI.cs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public void Initialize(string sourceCode, string resultCode)
3232
_sourceCode = sourceCode;
3333
_resultCode = resultCode;
3434
_defaultCommand = $"- Translate to {resultCode}, keep special characters, and output only the translation.";
35-
//_defaultCommand = $"- {_sourceCode} -> {_resultCode} result only";
3635
}
3736

3837
public void InitializeModel(string model, string apiKey, bool useDefaultModel)
@@ -92,15 +91,10 @@ private async Task<string> InternalTranslateTextAsync(string requestText, string
9291
new { role = "user", parts = new[] { new { text = requestText } } }
9392
},
9493

95-
9694
generationConfig = new
9795
{
98-
//추론기능 - 0은 끈 상태
99-
thinkingConfig = new
100-
{
101-
thinkingBudget = 0
102-
},
103-
temperature = 0.2f // float 값으로 설정 (0.0f ~ 1.0f 사이)
96+
thinkingConfig = new { thinkingBudget = 0 },
97+
temperature = 0.2f
10498
}
10599

106100
/*
@@ -183,40 +177,43 @@ private async Task<string> InternalTranslateTextAsync(string requestText, string
183177
private void InitializeCommand()
184178
{
185179
_resultCommand = "";
186-
bool useCommand = false;
180+
181+
// 1. 커스텀 명령이 있다면 먼저 추가 (예: "- 무조건 경어로 번역해줘")
187182
if(!string.IsNullOrEmpty(_command))
188183
{
189184
_resultCommand += $"- {_command}";
190-
useCommand = true;
191185
}
192186

193-
if(!useCommand || (useCommand && !_disableDefaultCommand))
187+
// 2. 기본 명령을 추가해야 하는 경우
188+
// 조건: 커스텀 명령이 없거나 (useCommand = false)
189+
// 커스텀 명령이 있고 기본 명령을 비활성화하지 않은 경우
190+
bool useDefault = string.IsNullOrEmpty(_command) || (!_disableDefaultCommand);
191+
192+
if(useDefault)
194193
{
195-
if(useCommand)
194+
// 3. 커스텀 명령이 이미 있을 경우에만 공백(' ') 하나를 삽입하여 토큰 낭비 최소화
195+
if(!string.IsNullOrEmpty(_resultCommand))
196196
{
197-
_resultCommand += System.Environment.NewLine;
197+
_resultCommand += " ";
198198
}
199+
200+
// 4. 기본 명령 추가
199201
_resultCommand += $"{_defaultCommand}";
200202
}
201203

202-
203204
_inited = true;
204205
}
205206

206-
private string CombineText(string text)
207+
private string CombineTextOptimized(string text)
207208
{
208209
if(!string.IsNullOrEmpty(_command) && _disableDefaultCommand)
209210
{
210-
return _command + System.Environment.NewLine + System.Environment.NewLine + text;
211+
return _command + " " + text;
211212
}
212-
213-
return "**Command:**" + System.Environment.NewLine + System.Environment.NewLine + _resultCommand + System.Environment.NewLine + System.Environment.NewLine + "**Text to Translate**" + System.Environment.NewLine + System.Environment.NewLine + text;
213+
return _resultCommand + " " + text;
214214
}
215215

216216

217-
218-
219-
220217

221218
public async Task<string> TranslateTextAsync(string text, CancellationToken token)
222219
{
@@ -225,8 +222,7 @@ public async Task<string> TranslateTextAsync(string text, CancellationToken toke
225222
InitializeCommand();
226223
}
227224

228-
229-
string command = CombineText(text);
225+
string command = CombineTextOptimized(text);
230226
string result = await InternalTranslateTextAsync(command, text, false, token);
231227
return result;
232228
}

MORT/app.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@
7373
<applicationSettings>
7474
<MORT.Properties.Settings>
7575
<setting name="MORT_VERSION" serializeAs="String">
76-
<value>1.304V - Test2</value>
76+
<value>1.305V</value>
7777
</setting>
7878
<setting name="LAYER_TEXT" serializeAs="String">
7979
<value>MORT {0}
8080
레이어 번역창</value>
8181
</setting>
8282
<setting name="MORT_VERSION_VALUE" serializeAs="String">
83-
<value>1304</value>
83+
<value>1305</value>
8484
</setting>
8585
<setting name="TOOLTIP_LIST" serializeAs="String">
8686
<value>MORT를 처음 쓰시면 그 외-&gt; MORT 사용법을 확인해 주세요,
@@ -115,7 +115,7 @@ OCR 영역을 빠르게 추가하고 싶을 땐 빠른 OCR 영역을 사용하
115115
구글 OCR의 사용량은 실제 사용량과 다를 수 있습니다. 수시로 구글 콘솔에서 확인하셔야 합니다</value>
116116
</setting>
117117
<setting name="MORT_RELEASE" serializeAs="String">
118-
<value>2025 12 12</value>
118+
<value>2025 12 14</value>
119119
</setting>
120120
<setting name="BASIC_TEXT" serializeAs="String">
121121
<value>Monkeyhead's OCR Realtime TransLate {0}

0 commit comments

Comments
 (0)