Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
コメントアウトや無駄な変数などの修正。
Browse files Browse the repository at this point in the history
  • Loading branch information
yutateno committed Dec 1, 2018
1 parent 3cb5d6a commit 6aadfd4
Show file tree
Hide file tree
Showing 39 changed files with 86 additions and 40 deletions.
Binary file modified ColorVisionCorrection/ColorVisionCorrection/Log.txt
Binary file not shown.
126 changes: 86 additions & 40 deletions ColorVisionCorrection/ColorVisionCorrection/main.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
/*
透過画像は考慮していません。他プロジェクトとして作る予定です。
*/

#include "DxLib.h"
#include "DxLib.h"

// 画像の対応する最大サイズ
int XSize = 2048;
int YSize = 2048;

int RGBA[2048][2048][4]; // 元なるRGBをピクセル単位で取得
double XYZ[2048][2048][3]; // RGBからXYZに変換したもの
double PXYZ[2048][2048][3]; // LMSから直接P型異常のXYZに変換
double DXYZ[2048][2048][3]; // LMSから直接D型異常のXYZに変換
double LMS[2048][2048][3]; // XYZからLMSに変換したもの
double PLMS[2048][2048][3]; // LMSからP型異常に変換したもの
double DLMS[2048][2048][3]; // LMSからD型異常に変換したもの
int DRGB[2048][2048][3]; // DXYZからRGBに変換したもの
int PRGB[2048][2048][3]; // PLMSからRGBに変換したもの

// 元なるRGBをピクセル単位で取得
int RGBA[2048][2048][4];

// RGBからXYZに変換したもの
double XYZ[2048][2048][3];

// LMSから直接P型異常のXYZに変換
double PXYZ[2048][2048][3];

// LMSから直接D型異常のXYZに変換
double DXYZ[2048][2048][3];

// XYZからLMSに変換したもの
double LMS[2048][2048][3];

// LMSからP型異常に変換したもの
double PLMS[2048][2048][3];

// LMSからD型異常に変換したもの
double DLMS[2048][2048][3];

// DXYZからRGBに変換したもの
int DRGB[2048][2048][3];

// PLMSからRGBに変換したもの
int PRGB[2048][2048][3];


int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
Expand All @@ -33,31 +48,41 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

bool jpgExtension = false; // jpgでは透過できないのでそれの判断

int handle, normal = -1;
int handle = -1;
int normal = -1;


// 画像のドラッグアンドドロップで起動していないとき
if (__argc == 1)
{
// ここで保存する画像を決める(ちゃんとしたものを作りたいが簡単にする)
// ここで保存する画像を決める(拡張子探索にしてもいいが楽したいので簡単にする)
// pngでロードする
normal = LoadGraph("Media.png");
handle = LoadSoftImage("Media.png");

// 失敗したのでjpgでロードする
if (normal == -1)
{
normal = LoadGraph("Media.jpg");
handle = LoadSoftImage("Media.jpg");
jpgExtension = true;
}

// 失敗したのでbmpでロードする
if (normal == -1)
{
normal = LoadGraph("Media.bmp");
handle = LoadSoftImage("Media.bmp");
jpgExtension = true;
}

// エラー終了
if (normal == -1)
{
return -1;
}
}
// ドラッグアンドドロップで起動したとき
else
{
// ここで保存する画像を決める(ちゃんとしたものを作りたいが簡単にする)
Expand All @@ -68,41 +93,51 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
mediaFile = strrchr(dragFile, ch) + 1;

const char *Pexe = NULL;

// pngで探索する
Pexe = strstr(mediaFile, "png");

// ロードする
if (Pexe != NULL)
{
normal = LoadGraph(mediaFile);
handle = LoadSoftImage(mediaFile);
Pexe = NULL;
}
if (normal == -1)
// 探索して見つからなかった
else
{
const char *Jexe = NULL;
Jexe = strstr(mediaFile, "jpg");
if (Jexe != NULL)
// jpgで探索する
Pexe = strstr(mediaFile, "jpg");

// ロードする
if (Pexe != NULL)
{
normal = LoadGraph(mediaFile);
handle = LoadSoftImage(mediaFile);
jpgExtension = true;
Jexe = NULL;
}
}
if (normal == -1)
{
const char *Bexe = NULL;
Bexe = strstr(mediaFile, "bmp");
if (Bexe != NULL)
// 探索して見つからなかった
else
{
normal = LoadGraph(mediaFile);
handle = LoadSoftImage(mediaFile);
jpgExtension = true;
Bexe = NULL;
// bmpで探索する
Pexe = strstr(mediaFile, "bmp");

// ロードする
if (Pexe != NULL)
{
normal = LoadGraph(mediaFile);
handle = LoadSoftImage(mediaFile);
jpgExtension = true;
}
}
}

// ロードできなかったのでエラー終了する
if (normal == -1)
{
return -1;
}
Pexe = NULL;
dragFile = NULL;
mediaFile = NULL;
}
Expand All @@ -118,6 +153,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

int completeHandle_D, completeHandle_P, completeHandle_Mono; // 空の画像から作った画像を渡すもの


// ピクセルごとの色を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -129,6 +165,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

DeleteSoftImage(handle); // 用がないので削除


// XYZ色空間を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -140,6 +177,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
}
}


// LMS色空間を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -151,6 +189,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
}
}


// P型異常のLMS色空間を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -162,6 +201,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
}
}


// D型異常のLMS色空間を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -173,6 +213,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
}
}


// P型異常のXYZ色空間を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -184,6 +225,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
}
}


// D型異常のXYZ色空間を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -195,6 +237,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
}
}


// D型異常のRGB色空間を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -210,6 +253,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
completeHandle_D = CreateGraphFromSoftImage(changeHandle_D); // Softimageからグラフィックハンドルを作成する
DeleteSoftImage(changeHandle_D); // いらなくなったので削除


// P型異常のRGB色空間を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -225,6 +269,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
completeHandle_P = CreateGraphFromSoftImage(changeHandle_P); // Softimageからグラフィックハンドルを作成する
DeleteSoftImage(changeHandle_P); // いらなくなったので削除


// 白黒画像を得る
for (int x = 0; x < XSize; ++x)
{
Expand All @@ -238,6 +283,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
completeHandle_Mono = CreateGraphFromSoftImage(changeHandle_Mono); // Softimageからグラフィックハンドルを作成する
DeleteSoftImage(changeHandle_Mono); // いらなくなったので削除


int count = 0; // 描画して確認するなどの一連の動作を時間で行うための変数

// 本編
Expand All @@ -246,47 +292,47 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
count++; // 加算する

// 通常画像
if (count <= 60)
if (count <= 20)
{
DrawGraph(0, 0, normal, true); // 表示
// 保存
if (count == 60)
if (count == 20)
{
SaveDrawScreenToJPEG(0, 0, XSize, YSize, "correction\\normal.jpg"); // JPG
SaveDrawScreenToBMP(0, 0, XSize, YSize, "correction\\normal.bmp"); // BMP
SaveDrawScreenToPNG(0, 0, XSize, YSize, "correction\\normal.png"); // PNG
}
}
// D型色覚画像
else if (count <= 120)
else if (count <= 40)
{
DrawGraph(0, 0, completeHandle_D, true); // 表示
// 保存
if (count == 120)
if (count == 40)
{
SaveDrawScreenToJPEG(0, 0, XSize, YSize, "correction\\D.jpg"); // JPG
SaveDrawScreenToBMP(0, 0, XSize, YSize, "correction\\D.bmp"); // BMP
SaveDrawScreenToPNG(0, 0, XSize, YSize, "correction\\D.png"); // PNG
}
}
// P型色覚画像
else if (count <= 180)
else if (count <= 60)
{
DrawGraph(0, 0, completeHandle_P, true); // 表示
// 保存
if (count == 180)
if (count == 60)
{
SaveDrawScreenToJPEG(0, 0, XSize, YSize, "correction\\P.jpg"); // JPG
SaveDrawScreenToBMP(0, 0, XSize, YSize, "correction\\P.bmp"); // BMP
SaveDrawScreenToPNG(0, 0, XSize, YSize, "correction\\P.png"); // PNG
}
}
// 白黒画像
else if (count <= 240)
else if (count <= 80)
{
DrawGraph(0, 0, completeHandle_Mono, true); // 表示
// 保存
if (count == 240)
if (count == 80)
{
SaveDrawScreenToJPEG(0, 0, XSize, YSize, "correction\\whiteblack.jpg"); // JPG
SaveDrawScreenToBMP(0, 0, XSize, YSize, "correction\\whiteblack.bmp"); // BMP
Expand Down
Binary file not shown.
Binary file modified ColorVisionCorrection/ColorVisionCorrection/x64/Debug/vc141.idb
Binary file not shown.
Binary file modified ColorVisionCorrection/ColorVisionCorrection/x64/Debug/vc141.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ColorVisionCorrection/x64/Debug/ColorVisionCorrection.ilk
Binary file not shown.
Binary file modified ColorVisionCorrection/x64/Debug/ColorVisionCorrection.pdb
Binary file not shown.
Binary file modified ColorVisionCorrection/x64/Release/ColorVisionCorrection.iobj
Binary file not shown.
Binary file modified ColorVisionCorrection/x64/Release/ColorVisionCorrection.ipdb
Binary file not shown.
Binary file modified ColorVisionCorrection/x64/Release/ColorVisionCorrection.pdb
Binary file not shown.
Binary file modified ColorVisionCorrection/x64/Release/Log.txt
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Release/Log.txt
Binary file not shown.
Binary file added Release/correction/D.bmp
Binary file not shown.
Binary file added Release/correction/D.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Release/correction/D.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Release/correction/P.bmp
Binary file not shown.
Binary file added Release/correction/P.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Release/correction/P.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Release/correction/normal.bmp
Binary file not shown.
Binary file added Release/correction/normal.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Release/correction/normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Release/correction/whiteblack.bmp
Binary file not shown.
Binary file added Release/correction/whiteblack.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Release/correction/whiteblack.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6aadfd4

Please sign in to comment.