typedef struct {
unsigned char vers;
unsigned char stab;
unsigned char vers2;
unsigned char stab2;
unsigned short int leftSiz;
unsigned short int nameLen;
char name[0x180];
unsigned char vers3;
unsigned short int focalLen;
unsigned char vers4;
unsigned char Fvalue;
unsigned char FvalueDecimal; // v/100
signed char Vignetting1; // Luminas
signed char Vignetting2; // Red
signed char Vignetting3; // Blue
signed char LateralChromaticAberration1; // Red
signed char LateralChromaticAberration2; // Blue
signed char Distortion;
unsigned char stab3[0x5c];
} lensProf_t;
lensProf_t lensProf;
void swabWrite(unsigned short int *p, unsigned short int little)
{
char *q = (char *)p;
*q++ = little >> 8;
*q = little & 0xff;
return;
}
unsigned short int swabRead(unsigned short int *p)
{
unsigned char *q = (unsigned char *)p;
unsigned short int little;
little = *q++ << 8;
little += *q & 0xff;
return little;
}
int _tmain(int argc, _TCHAR* argv[])
{
int j = 1;
char outName[/*_MAX_DIR+*/_MAX_FNAME+_MAX_EXT+1];
FILE* inFile;
FILE* extFile;
名前:bombo (ID:8a6f0ee60bea)
ギャオス流、7R2写真ですね。
すごくいいです。
確かにレンズ補正アプリは使いにくい。
設定が変わるのはなんとか慣れそうな気もしますが、
パラメータ入力のめんどくさいこと。
せめて、PCで編集して転送できるようにしてほしい。
名前:ギャオス (ID:58446ebd8a7e)
bomboさん、ありがとうございます。
ギャオス流、気に入って頂けたようで光栄です。
EVFが凄くイイので、ついつい無駄に除いたりしております。w
名前:gigo (ID:7d723be021c8)
>せめて、PCで編集して転送できるようにしてほしい。
Windowsコンソールアプリですが。
FreeのVisual studioでコンパイル出来ます。
// LensProf.cpp
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <io.h>
#define FILESIZE 0x200
#define VERS 0x00
#define VERS2 0x02
#define LEFTSIZ 0x04 //(FILESIZE-6)
#define NAMELEN 0x06
#define NAMESTR 0x08
#define VERS3 0x188
#define FOCAL 0x189
#define VERS4 0x18B
#define FVAL 0x18C
#define FVALDEC 0x18D
#define VIGNET1 0x18E
#define VIGNET2 0x18F
#define VIGNET3 0x190
#define LCA1 0x191 //LateralChromaticAberration
#define LCA2 0x192
#define DIST 0x193
#pragma pack(1)
typedef struct {
unsigned char vers;
unsigned char stab;
unsigned char vers2;
unsigned char stab2;
unsigned short int leftSiz;
unsigned short int nameLen;
char name[0x180];
unsigned char vers3;
unsigned short int focalLen;
unsigned char vers4;
unsigned char Fvalue;
unsigned char FvalueDecimal; // v/100
signed char Vignetting1; // Luminas
signed char Vignetting2; // Red
signed char Vignetting3; // Blue
signed char LateralChromaticAberration1; // Red
signed char LateralChromaticAberration2; // Blue
signed char Distortion;
unsigned char stab3[0x5c];
} lensProf_t;
lensProf_t lensProf;
void swabWrite(unsigned short int *p, unsigned short int little)
{
char *q = (char *)p;
*q++ = little >> 8;
*q = little & 0xff;
return;
}
unsigned short int swabRead(unsigned short int *p)
{
unsigned char *q = (unsigned char *)p;
unsigned short int little;
little = *q++ << 8;
little += *q & 0xff;
return little;
}
int _tmain(int argc, _TCHAR* argv[])
{
int j = 1;
char outName[/*_MAX_DIR+*/_MAX_FNAME+_MAX_EXT+1];
FILE* inFile;
FILE* extFile;
if (argc == 2) { //read
if (fopen_s(&inFile,argv[1],"rb")!=0) {
fprintf(stderr,"\n*Error - can't open file '%s'(%d) !\n",argv[1],errno);
return(errno);
}
if (fread(&lensProf, sizeof(lensProf), 1, inFile)!= 1) {
printf("\nError - can't read.\n\n");
return(errno);
}
fclose(inFile);
printf("\"%s\" %d %3.2f %d %d %d %d %d %d\n"
,&lensProf.name[0]
,swabRead(&lensProf.focalLen)
,(double)lensProf.Fvalue+lensProf.FvalueDecimal/100.0
,lensProf.Vignetting1
,lensProf.Vignetting2
,lensProf.Vignetting3
,lensProf.LateralChromaticAberration1
,lensProf.LateralChromaticAberration2
,lensProf.Distortion
);
(void) getchar();
return(0);
}
if (argc >= 4) { // create
char *l=argv[1];
double f = atof(argv[3]);
memset(&lensProf,0,sizeof(lensProf));
lensProf.vers = 1;
lensProf.vers2 = 1;
lensProf.vers3 = 1;
lensProf.vers4 = 1;
swabWrite(&lensProf.leftSiz,sizeof(lensProf)-6);
memcpy(&lensProf.name[0],l,strlen(l));
swabWrite(&lensProf.nameLen,strlen(&lensProf.name[0]));
swabWrite(&lensProf.focalLen,atoi(argv[2]));
lensProf.Fvalue = int(f);
lensProf.FvalueDecimal = (unsigned)((f-int(f)+0.005)*100);
if (argc >= 5) {
lensProf.Vignetting1 = atoi(argv[4]);
if (argc >= 6) {
lensProf.Vignetting2 = atoi(argv[5]);
if (argc >= 7) {
lensProf.Vignetting3 = atoi(argv[6]);
if (argc >= 8) {
lensProf.LateralChromaticAberration1 = atoi(argv[7]);
if (argc >= 9) {
lensProf.LateralChromaticAberration2 = atoi(argv[8]);
if (argc >= 10)
lensProf.Distortion = atoi(argv[9]);
}
}
}
}
}
do {
sprintf_s(outName,_MAX_FNAME+_MAX_EXT,"LENS%04d.BIN",j++);
if (j>200) { // 200 file Max.
fprintf(stderr,"Error: can't rename - '%s'\n",outName);
return(EXIT_FAILURE);
}
} while (_access(outName, 0) != -1);
if (fopen_s(&extFile,outName,"wb+")!=0) {
fprintf(stderr,"\n*Error - can't open file '%s'(%d) !\n",outName,errno);
perror("24");
}
printf("'%s'",outName);
if (fwrite(&lensProf, sizeof(lensProf), 1, extFile)!= 1) {
printf("\nError - can't write.\n\n");
return errno;
}
fclose(extFile);
printf("\"%s\" %d %3.2f %d %d %d %d %d %d\n"
,&lensProf.name[0]
,swabRead(&lensProf.focalLen)
,(double)lensProf.Fvalue+lensProf.FvalueDecimal/100.0
,lensProf.Vignetting1
,lensProf.Vignetting2
,lensProf.Vignetting3
,lensProf.LateralChromaticAberration1
,lensProf.LateralChromaticAberration2
,lensProf.Distortion
);
return 0;
}
fprintf(stderr,"Usage:\n");
fprintf(stderr," LensProf File\n");
fprintf(stderr," LensProf \"LensName\" FocalLength Fvalue [[[[[[V1] V2] V3] L1] L2] Ds]\n");
(void) getchar();
return EXIT_FAILURE;
}
名前:bombo (ID:5e57ec1562de)
gigoさん、ありがとうございます。
帰ったら試してみます。
gigo って、garbage in, garbage out の略なんですか。
名前:gigo (ID:7d723be021c8)
そうです。hpの先頭に書いてある通りです。
名前:Demelza (ID:9e5822491e5c)
In the coeimpcatld world we live in, it's good to find simple solutions.