Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KenPanCS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QCD
Tools
KenPanCS
Commits
5584ca82
Commit
5584ca82
authored
Dec 19, 2021
by
AP matsuo koji
😲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aRGB4チャンネル保存からRGB3チャンネルに変更
parent
cde22144
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
7 deletions
+44
-7
CSRender.cs
CSRender/CSRender.cs
+38
-4
AssemblyInfo.cs
CSRender/Properties/AssemblyInfo.cs
+5
-3
CSRender_ReadMe.txt
CSRender_ReadMe.txt
+1
-0
CSRender.exe
bin/Release/CSRender.exe
+0
-0
No files found.
CSRender/CSRender.cs
View file @
5584ca82
...
...
@@ -170,6 +170,41 @@ namespace CSRender {
return
pageCount
;
// ページ数を返却します
}
/// <summary>
/// imageをRGB3チェンネルbitmapにRenderingする
/// </summary>
/// <returns></returns>
public
static
System
.
Drawing
.
Bitmap
RenderRgbBitMap
(
PdfiumViewer
.
PdfDocument
docG
,
int
index
,
double
dpiX
,
double
dpiY
,
PdfRenderFlags
flg
){
var
bitmap
=
docG
.
Render
(
index
,
(
float
)
dpiX
,
(
float
)
dpiY
,
flg
)
as
System
.
Drawing
.
Bitmap
;
if
(
bitmap
.
PixelFormat
==
System
.
Drawing
.
Imaging
.
PixelFormat
.
Format24bppRgb
)
return
bitmap
;
//
var
cloneRect
=
new
System
.
Drawing
.
RectangleF
(
0
,
0
,
bitmap
.
Size
.
Width
,
bitmap
.
Size
.
Height
);
var
format
=
System
.
Drawing
.
Imaging
.
PixelFormat
.
Format24bppRgb
;
var
clonebitmap
=
bitmap
.
Clone
(
cloneRect
,
format
);
//
//bitmap.Dispose();
return
clonebitmap
;
/*
保存時にBitmapのクローンを作成し、その際のBitmapの形式に24bitRGB(PixelFormat.Format24bppRgb)を
指定し3版RGBTiffを出力します。
System.Drawing.Imaging.PixelFormat format = PixelFormat.Format24bppRgb;
clonebitmap = bitmap1.Clone(cloneRect, format);
ref:
https://maywork.net/computer/csharp_convert_to_format32bppargb/
https://www.webdevqa.jp.net/ja/c%23/c%EF%BC%83%E3%81%A7%E3%81%AE%E3%83%93%E3%83%83%E3%83%88%E3%83%9E%E3%83%83%E3%83%97pixelformats%E3%81%AE%E5%A4%89%E6%8F%9B/968763414/
https://gist.github.com/nissuk/888601/ee0943dd0d35dc9c6b47358b9e1a89af8cc9898b
https://stackoverflow.com/questions/28448474/render-pdf-page-to-bitmap-using-pdfium
https://qiita.com/Nuits/items/4a2fbc0f4e8583bd5531
PixelFormat dump https://maywork.net/computer/csharp_convert_to_format32bppargb/
*/
}
/// <summary>
/// pdfのページを画像に出力する
/// </summary>
/// <param name="doc">PdfDocument</param>
...
...
@@ -193,9 +228,8 @@ namespace CSRender {
using
(
var
memStrm
=
new
MemoryStream
())
{
PdfRenderFlags
flg
=
(
PdfRenderFlags
.
ForPrinting
|
PdfRenderFlags
.
CorrectFromDpi
);
using
(
var
img
=
docG
.
Render
(
index
,
(
float
)
pm
.
Dpi
,
(
float
)
pm
.
Dpi
,
flg
)
){
using
(
var
img
=
RenderRgbBitMap
(
docG
,
index
,
(
float
)
pm
.
Dpi
,
(
float
)
pm
.
Dpi
,
flg
)
){
img
.
Save
(
memStrm
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Bmp
);
//img.Save(memStrm, System.Drawing.Imaging.ImageFormat.Jpeg);
/*
// ImageFormatJPEGの時
dpi = 350,TIFF
...
...
@@ -225,7 +259,7 @@ namespace CSRender {
img
.
Dispose
();
}
var
bmp
=
new
System
.
Drawing
.
Bitmap
(
memStrm
);
if
(
bDump
)
{
if
(
bDump
)
{
echo
(
$"bmp=w:
{
bmp
.
Size
.
Width
}
,h:
{
bmp
.
Size
.
Height
}
"
);
}
//Console.WriteLine($"OrgReso({bmp.HorizontalResolution},{bmp.VerticalResolution})");
...
...
@@ -461,7 +495,7 @@ namespace CSRender {
if
(
pm
==
null
)
pm
=
new
RenderConditionParams
();
PdfRenderFlags
flg
=
(
PdfRenderFlags
.
ForPrinting
|
PdfRenderFlags
.
CorrectFromDpi
);
System
.
Drawing
.
Image
img
=
docG
.
Render
(
index
,
(
float
)
pm
.
Dpi
,
(
float
)
pm
.
Dpi
,
flg
);
System
.
Drawing
.
Image
img
=
RenderRgbBitMap
(
docG
,
index
,
(
float
)
pm
.
Dpi
,
(
float
)
pm
.
Dpi
,
flg
);
img
.
Save
(
memStrm
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Bmp
);
//img.Save(memStrm, System.Drawing.Imaging.ImageFormat.Jpeg);
// [注意] PDFuim用にFlush()必要
...
...
CSRender/Properties/AssemblyInfo.cs
View file @
5584ca82
...
...
@@ -33,11 +33,13 @@ using System.Runtime.InteropServices;
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.3.
1
.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3.
1
.0"
)]
[
assembly
:
AssemblyVersion
(
"1.3.
2
.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.3.
2
.0"
)]
[
assembly
:
NeutralResourcesLanguage
(
"ja"
)]
// rev:1.3.1.x:2021/10/05 :不要コード削除(Windows.Data.pdf)
// rev:1.3.2.0:2021/12/20 :aRGB4チャンネル保存からRGB3チャンネルに変更
// rev:1.3.1.0:2021/10/05 :不要コード削除(Windows.Data.pdf)
// rev:1.3.0.5:2021/09/14 :/Paraで並行プロセス最大値の設定追加
// rev:1.3.0.4:2021/04/29 :Helpの記述抜け "/Result"の対応
// rev:1.3.0.3:2020/11/22 :/Result <比較結果> を実装。diff画像を出力
...
...
CSRender_ReadMe.txt
View file @
5584ca82
V1.3.2.0:2021/12/20 :aRGB4チャンネル保存からRGB3チャンネルに変更
V1.3.1.0:2021/10/04 :UWP用、Data.pdfの削除、整理
* UWP用コード削除。通常のファイルアクセスやMemoryStreamに変更
* Widnows RT Windows.Data.pdfの使用を削除.PDFiumのみとした
...
...
bin/Release/CSRender.exe
View file @
5584ca82
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment