Skip to content

feat: 그림 밝기/대비 효과 SVG 반영 (#150)#387

Closed
oksure wants to merge 1 commit into
edwardkim:mainfrom
oksure:contrib/image-brightness-contrast
Closed

feat: 그림 밝기/대비 효과 SVG 반영 (#150)#387
oksure wants to merge 1 commit into
edwardkim:mainfrom
oksure:contrib/image-brightness-contrast

Conversation

@oksure

@oksure oksure commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

배경

PR #149에서 그레이스케일/흑백 효과가 구현되었으나, 밝기(brightness)와 대비(contrast) 속성은 파싱만 되고 SVG 출력에 반영되지 않았습니다.

변경 사항

  • ImageNodebrightness: i8, contrast: i8 필드 추가
  • 8개 ImageNode 생성 지점에서 pic.image_attr.brightness/contrast 전달
  • SVG <feComponentTransfer> 필터로 밝기/대비 조정 구현
  • 기존 효과 필터(그레이스케일/흑백)와 중첩 <g filter> 래핑으로 조합

필터 수식

slope = (100 + contrast) / 100
intercept = (0.5 - 0.5 × slope) + brightness / 100

테스트

  • cargo test: 1008 통과
  • cargo clippy -- -D warnings: 경고 0건
  • SVG 스냅샷 테스트 6건 모두 통과 (회귀 없음)

Closes #150

…m#150)

ImageAttr.brightness and contrast were already parsed from HWP/HWPX
but never passed to the render tree or applied in SVG output.

Changes:
- Add brightness/contrast fields to ImageNode (render tree)
- Pass values from ImageAttr through all 8 construction sites
- Generate feComponentTransfer SVG filter for brightness/contrast
- Combine with existing effect filters (grayscale/monochrome) via
  nested <g filter> wrappers

The filter uses linear slope/intercept:
- slope = (100 + contrast) / 100
- intercept = (0.5 - 0.5 * slope) + brightness / 100

Closes edwardkim#150
Copilot AI review requested due to automatic review settings April 27, 2026 11:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

밝기(brightness)·대비(contrast) 속성이 파싱만 되고 SVG 출력에 반영되지 않던 문제(#150)를 해결하기 위해, ImageNode에 해당 속성을 전달/보관하고 SVG 필터(<feComponentTransfer>)로 렌더링에 적용합니다.

Changes:

  • ImageNodebrightness: i8, contrast: i8 필드 추가 및 기본값(0) 설정
  • ImageNode 생성 지점들에서 pic.image_attr.brightness/contrast 전달
  • SVG 렌더링 시 밝기/대비 필터를 lazy 등록하고 기존 효과 필터와 중첩 <g filter>로 조합

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/renderer/svg.rs 밝기/대비용 SVG 필터를 defs에 등록하고 이미지 렌더링 시 필터 래핑 적용
src/renderer/render_tree.rs ImageNode에 brightness/contrast 필드 추가 및 기본값 반영
src/renderer/layout/table_cell_content.rs 표 셀 내 Picture → ImageNode 생성 시 brightness/contrast 전달
src/renderer/layout/shape_layout.rs 그룹 내 Picture → ImageNode 생성 시 brightness/contrast 전달
src/renderer/layout/picture_footnote.rs 머리말/꼬리말 Picture → ImageNode 생성 시 brightness/contrast 전달
src/renderer/layout/paragraph_layout.rs 인라인 Picture(TAC) 렌더링 경로들에 brightness/contrast 전달
src/renderer/layout.rs paragraph_layout 미호출 케이스에서 인라인 Picture 생성 시 brightness/contrast 전달

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +962 to +963
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

brightness/contrast 필드가 다른 필드들과 들여쓰기/정렬이 깨진 상태로 들어가 있어 가독성이 떨어집니다. rustfmt 기준으로 정렬되도록 들여쓰기를 맞추거나 cargo fmt로 포맷을 정리해 주세요.

Suggested change
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,

Copilot uses AI. Check for mistakes.
Comment on lines +1705 to +1706
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

새로 추가된 brightness/contrast 라인이 주변 필드들과 정렬되지 않아 읽기 어렵습니다. rustfmt 기준으로 들여쓰기를 맞추거나 cargo fmt로 포맷을 정리해 주세요.

Suggested change
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,

Copilot uses AI. Check for mistakes.
Comment on lines +1957 to +1958
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

ImageNode { ... } 초기화에서 brightness/contrast 들여쓰기/정렬이 깨져 가독성이 떨어집니다. rustfmt 기준으로 정렬되도록 포맷을 정리해 주세요.

Suggested change
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,

Copilot uses AI. Check for mistakes.
Comment on lines +2042 to +2043
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

여기 brightness/contrast 추가 부분이 주변 필드와 들여쓰기/정렬이 맞지 않습니다. 동일한 스타일로 정렬되도록 포맷을 정리해 주세요(가능하면 cargo fmt).

Suggested change
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,
brightness: pic.image_attr.brightness,
contrast: pic.image_attr.contrast,

Copilot uses AI. Check for mistakes.
@edwardkim

Copy link
Copy Markdown
Owner

PR 검토했습니다.

코드 변경 (밝기/대비 `` 필터 + ImageNode 필드 추가) 은 명확하고 CI 도 통과 상태입니다. 다만 본 PR 의 base 가 `main` 으로 설정 되어 있어 main 브랜치 보호 정책으로 BLOCKED 상태입니다.

rhwp 프로젝트의 머지 워크플로우는 다음과 같습니다:

```
컨트리뷰터 PR → devel (개발 통합) → 릴리즈 시점에 devel → main + 태그
```

따라서 직접 `main` 으로의 PR 은 받지 않습니다. 본 PR 은 close 하시고, `devel` 브랜치 기반으로 다시 PR 을 요청해 주시면 정상 절차로 검토 가능합니다.

재PR 절차:

  1. 로컬에서 `devel` 최신 fetch
  2. 새 브랜치를 `devel` 위에 생성 (예: `contrib/image-brightness-contrast-v2`)
  3. 본 PR 의 commit (`f770e1c`) 을 cherry-pick 또는 동일 변경을 새로 commit
  4. base=`devel` 로 PR 생성

devel 에는 본 PR 이후 머지된 변경 (PR #366 / #371 / #373 / #385) 이 있어 충돌 가능성이 있습니다. 특히 PR #385 가 `render_tree.rs` 의 `ImageNode` 에 `Serialize` derive 를 추가했으므로 충돌 시 통합 부탁드립니다.

수고하셨습니다.

상세 검토: `mydocs/pr/pr_387_review.md`

edwardkim added a commit that referenced this pull request Apr 27, 2026
- 이슈 #377: bytes 반환 API 이미 제공 안내 + 위키 가이드 링크 + close
- mydocs/feedback/issue_377_export_api_review.md 추가
- mydocs/orders/20260426.md 갱신
- mydocs/pr/pr_387_review.md, pr_388_review.md (devel 기반 재PR 안내 후 작성자 close 대기)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oksure

oksure commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

검토 감사합니다. main 으로 직접 PR 을 올린 점 죄송합니다. devel 기반으로 재작업하여 새 PR 을 올리겠습니다. 본 PR 은 close 합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

그림 효과: 밝기/대비/워터마크 속성 SVG 반영

3 participants