⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpgapi.c

📁 JPEG DLL API
💻 C
📖 第 1 页 / 共 5 页
字号:
    UINT FocalPlaneYResolutionDen[1];
    
    UCHAR FocalPlaneYResolutionoffchar[4];
    UCHAR FocalPlaneYResolutionNumChar[4];
    UCHAR FocalPlaneYResolutionDenChar[4];

    //VARIABLES FOR THE FocalPlaneResolutionUnit
    UCHAR  FocalPlaneResolutionUnittag[2]={0x10,0xA2};    
    UCHAR  FocalPlaneResolutionUnitformat[2]={0x3,0x0};
    UCHAR  NcomponentFocalPlaneResolutionUnit[4]={0x1,0x0,0x0,0x0};    
    UINT   FocalPlaneResolutionUnit[1];
    UCHAR  FocalPlaneResolutionUnitChar[4] = {0};

    
    //VARIABLES FOR THE WHITE BALANCE PROGRAM OF THE CAMERA
    UCHAR  WhiteBalancetag[2]={0x07,0x00};    
    UCHAR  WhiteBalanceformat[2]={0x3,0x0};
    UCHAR  NcomponentWhiteBalance[4]={0x1,0x0,0x0,0x0};    
    UINT WhiteBalance[1];
    UCHAR  WhiteBalanceChar[4] = {0};

    //VARIABLES FOR THE USER COMMENTS
    UCHAR  UserCommentstag[2]={0x86,0x92};    
    UCHAR  UserCommentsformat[2]={0x7,0x0};
    UCHAR  NcomponentUserComments[4]={150,0x0,0x0,0x0};        
    UCHAR  UserComments[150];
    UCHAR UserCommentsoffchar[4];

    //VARIABLES FOR THE COMPRESSION TYPE
    UCHAR  Compressiontag[2]={0x03,0x01};    
    UCHAR  Compressionformat[2]={0x3,0x0};
    UCHAR  NcomponentCompression[4]={0x1,0x0,0x0,0x0};    
    UINT   Compression[1]={6};
    UCHAR  CompressionChar[4] = {0};

    //VARIABLES FOR THE JpegIFOffset 
    UCHAR  JpegIFOffsettag[2]={0x01,0x02};    
    UCHAR  JpegIFOffsetformat[2]={0x4,0x0};
    UCHAR  NcomponentJpegIFOffset[4]={0x1,0x0,0x0,0x0};        
    UCHAR  JpegIFOffsetChar[4] = {0};

    //VARIABLES FOR THE JpegIFByteCount 
    UCHAR  JpegIFByteCounttag[2]={0x02,0x02};    
    UCHAR  JpegIFByteCountformat[2]={0x4,0x0};
    UCHAR  NcomponentJpegIFByteCount[4]={0x1,0x0,0x0,0x0};        
    UCHAR  JpegIFByteCountChar[4] = {0};
    //END OF THE VARIABLES
    
    printD("makeExif\n");
    ExifInitialCount=tempExif;
    //for APP1 Marker(2 byte) and length(2 byte)
    tempExif += 4; 
    //write an exif header
    memcpy (tempExif, ExifHeader, 6);
    tempExif += 6 ;

    //write a tiff header
    memcpy (tempExif, TIFFHeader, 8);
    startoftiff=tempExif;
    tempExif += 8 ;
    //write no of entries in 1d0
    memcpy (tempExif, Nentries, 2);
    tempExif += 2 ;
    ///////////////ENTRY NO 1 :MAKE OF CAMERA////////////////////////
    //write make tag
    memcpy (tempExif, maketag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, makeformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, Ncomponent, 4);
    tempExif += 4 ;
    //write make
    //strcpy(make,tpJEInfo->Make);
    memcpy(make, jCtx->ExifInfo->Make,32);
    offset =(char*) 0x200;
    santemp=(int)(offset);
    makeoffchar[0]=(unsigned char)santemp;
    makeoffchar[1]=(unsigned char)(santemp>>8);
    makeoffchar[2]=(unsigned char)(santemp>>16);
    makeoffchar[3]=(unsigned char)(santemp>>24);
    //write the make offset into the bitstream
    memcpy (tempExif, makeoffchar, 4);
    tempExif += 4 ;
    memcpy (startoftiff+santemp, make, 32);
    offset+=32;
    
    ///////////////ENTRY NO 2 :MODEL OF CAMERA////////////////////////
    //write model tag
    memcpy (tempExif, modeltag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, modelformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentModel, 4); //sanjeev
    tempExif += 4 ;
    //write model
//    strcpy(model,tpJEInfo->Model);
    memcpy(model,jCtx->ExifInfo->Model,32);
    santemp=(int)(offset);
    modeloffchar[0]=(unsigned char)santemp;
    modeloffchar[1]=(unsigned char)(santemp>>8);
    modeloffchar[2]=(unsigned char)(santemp>>16);
    modeloffchar[3]=(unsigned char)(santemp>>24);
    //write the model offset into the bitstream
    memcpy (tempExif, modeloffchar, 4);
    tempExif += 4 ;
    memcpy (startoftiff+santemp, model, 32);
    offset+=32;    


    ///////////////ENTRY NO 3 :ORIENTATION OF CAMERA////////////////////////
    //write orientation tag
    memcpy (tempExif, orientationtag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, orientationformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentOrientation, 4);
    tempExif += 4 ;
    //write orientation mode
    Orientation[0] =jCtx->ExifInfo->Orientation;
    Orient[0] = (unsigned char)(Orientation[0]);
    Orient[1] = (unsigned char)(Orientation[0]>>8);
    Orient[2] = (unsigned char)(Orientation[0]>>16);
    Orient[3] = (unsigned char)(Orientation[0]>>24);

    memcpy (tempExif, Orient, 4);
    tempExif += 4 ;

        ///////////////ENTRY NO 4 :JPEG PROCESS////////////////////////
    //write orientation tag
    memcpy (tempExif, Processtag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, Processformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentProcess, 4);
    tempExif += 4 ;
    //write orientation mode
    Process[0] =jCtx->ExifInfo->Process;
    Proc[0] = (unsigned char)(Process[0]);
    Proc[1] = (unsigned char)(Process[0]>>8);
    Proc[2] = (unsigned char)(Process[0]>>16);
    Proc[3] = (unsigned char)(Process[0]>>24);

    memcpy (tempExif, Proc, 4);
    tempExif += 4 ;
    
        ///////////////ENTRY NO 5 :VERSION OF software////////////////////////
    //write VERSION tag
    memcpy (tempExif, Versiontag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, Versionformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentVersion, 4); //sanjeev
    tempExif += 4 ;
    
    
    santemp=(int)(offset);
    Versionoffchar[0]=(unsigned char)santemp;
    Versionoffchar[1]=(unsigned char)(santemp>>8);
    Versionoffchar[2]=(unsigned char)(santemp>>16);
    Versionoffchar[3]=(unsigned char)(santemp>>24);
    //write the VERSION offset into the bitstream
    memcpy (tempExif, Versionoffchar, 4);
    tempExif += 4 ;
//    strcpy(Version,jCtx->ExifInfo->Version);
    memcpy(Version,jCtx->ExifInfo->Version,32);
    memcpy (startoftiff+santemp, Version, 32);
    offset+=32;    
            ///////////////ENTRY NO 6 :Date/Time////////////////////////
    //write model tag
    memcpy (tempExif, DateTimetag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, DateTimeformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentDateTime, 4); //sanjeev
    tempExif += 4 ;
    //write Date/Time
    //strcpy(DateTime,jCtx->ExifInfo->DateTime);
    memcpy(DateTime,jCtx->ExifInfo->DateTime,20);
    
    santemp=(int)(offset);
    DateTimeoffchar[0]=(unsigned char)santemp;
    DateTimeoffchar[1]=(unsigned char)(santemp>>8);
    DateTimeoffchar[2]=(unsigned char)(santemp>>16);
    DateTimeoffchar[3]=(unsigned char)(santemp>>24);
    //write the model offset into the bitstream
    memcpy (tempExif, DateTimeoffchar, 4);
    tempExif += 4 ;
    memcpy (startoftiff+santemp, DateTime, 19);
    memcpy (startoftiff+santemp+19, DateTimeClose, 1);

    offset+=32;    
            ///////////////ENTRY NO 7 :COPYRIGHT INFO////////////////////////
    //write model tag
    memcpy (tempExif, CopyRighttag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, CopyRightformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentCopyRight, 4); //sanjeev
    tempExif += 4 ;

//    strcpy(CopyRight,jCtx->ExifInfo->CopyRight);////="copyright 2006";);
    memcpy(CopyRight,jCtx->ExifInfo->CopyRight,32);
    
    santemp=(int)(offset);
    CopyRightoffchar[0]=(unsigned char)santemp;
    CopyRightoffchar[1]=(unsigned char)(santemp>>8);
    CopyRightoffchar[2]=(unsigned char)(santemp>>16);
    CopyRightoffchar[3]=(unsigned char)(santemp>>24);
    //write the model offset into the bitstream
    memcpy (tempExif, CopyRightoffchar, 4);
    tempExif += 4 ;
    memcpy (startoftiff+santemp, CopyRight, 32);    

    offset+=32;    
    ///////////////ENTRY NO 8 :OFFSET TO THE SubIFD ////////////////////////
    //write SubIFD tag
    memcpy (tempExif, SubIFDOffsettag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, SubIFDOffsetformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentSubIFDOffset, 4);
    tempExif += 4 ;
    //write the  offset to the SubIFD
    santemp=(int)(tempExif-startoftiff+8);
    SubIFDOffsetChar[0] = (unsigned char)(santemp);
    SubIFDOffsetChar[1] = (unsigned char)(santemp>>8);
    SubIFDOffsetChar[2] = (unsigned char)(santemp>>16);
    SubIFDOffsetChar[3] = (unsigned char)(santemp>>24);

    memcpy (tempExif, SubIFDOffsetChar, 4);
    tempExif += 4 ;


    // since it was the last directory entry, so next 4 bytes contains an offset to the IFD1.

    //since we dont know the offset lets put 0x0000 as an offset, later when get to know the
    //actual offset we will revisit here and put the actual offset.
    santemp=0x0000;
    SubIFDOffsetChar[0] = (unsigned char)(santemp);
    SubIFDOffsetChar[1] = (unsigned char)(santemp>>8);
    SubIFDOffsetChar[2] = (unsigned char)(santemp>>16);
    SubIFDOffsetChar[3] = (unsigned char)(santemp>>24);
    IFD1OffsetAddress = tempExif;
    memcpy (tempExif, SubIFDOffsetChar, 4);
    tempExif += 4 ;
/////////////EXIF SUBIFD STARTS HERE//////////////////////////////////
    //write no of entries in SubIFD
    memcpy (tempExif, SubIFDNentries, 2);
    tempExif += 2 ;
///////////////ENTRY NO 1 : EXPOSURE TIME////////////////////////
    //write EXPOSURE TIME tag
    memcpy (tempExif, ExposureTimetag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, ExposureTimeformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentExposureTime, 4); 
    tempExif += 4 ;
    //write EXPOSURE TIME
    
    santemp=(int)(offset);
    ExposureTimeoffchar[0]=(unsigned char)santemp;
    ExposureTimeoffchar[1]=(unsigned char)(santemp>>8);
    ExposureTimeoffchar[2]=(unsigned char)(santemp>>16);
    ExposureTimeoffchar[3]=(unsigned char)(santemp>>24);
    //write the X-Resolution offset into the bitstream
    memcpy (tempExif, ExposureTimeoffchar, 4);
    tempExif += 4 ;

    ExposureTimeNum[0]=jCtx->ExifInfo->ExposureTimeNum;
    ExposureTimeDen[0]=jCtx->ExifInfo->ExposureTimeDen;
    ExposureTimeNumChar[0]=(unsigned char)ExposureTimeNum[0];
    ExposureTimeNumChar[1]=(unsigned char)(ExposureTimeNum[0]>>8);
    ExposureTimeNumChar[2]=(unsigned char)(ExposureTimeNum[0]>>16);
    ExposureTimeNumChar[3]=(unsigned char)(ExposureTimeNum[0]>>24);

    ExposureTimeDenChar[0]=(unsigned char)ExposureTimeDen[0];
    ExposureTimeDenChar[1]=(unsigned char)(ExposureTimeDen[0]>>8);
    ExposureTimeDenChar[2]=(unsigned char)(ExposureTimeDen[0]>>16);
    ExposureTimeDenChar[3]=(unsigned char)(ExposureTimeDen[0]>>24);

    //WRITE THE EXPOSURE TIME NUMERATOR
    memcpy (startoftiff+santemp, ExposureTimeNumChar, 4);

    memcpy (startoftiff+santemp+4, ExposureTimeDenChar, 4);
    
    offset+=32;
    ///////////////ENTRY NO 2 : F NUMBER////////////////////////
    //write FNumber tag
    memcpy (tempExif, FNumbertag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, FNumberformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentFNumber, 4); //sanjeev
    tempExif += 4 ;
    //write F NUMBER
    
    santemp=(int)(offset);
    FNumberoffchar[0]=(unsigned char)santemp;
    FNumberoffchar[1]=(unsigned char)(santemp>>8);
    FNumberoffchar[2]=(unsigned char)(santemp>>16);
    FNumberoffchar[3]=(unsigned char)(santemp>>24);
    //write the F NUMBER into the bitstream
    memcpy (tempExif, FNumberoffchar, 4);
    tempExif += 4 ;

    FNumberNum[0]=jCtx->ExifInfo->FNumberNum;
    FNumberDen[0]=jCtx->ExifInfo->FNumberDen;

    FNumberNumChar[0]=(unsigned char)FNumberNum[0];
    FNumberNumChar[1]=(unsigned char)(FNumberNum[0]>>8);
    FNumberNumChar[2]=(unsigned char)(FNumberNum[0]>>16);
    FNumberNumChar[3]=(unsigned char)(FNumberNum[0]>>24);

    FNumberDenChar[0]=(unsigned char)FNumberDen[0];
    FNumberDenChar[1]=(unsigned char)(FNumberDen[0]>>8);
    FNumberDenChar[2]=(unsigned char)(FNumberDen[0]>>16);
    FNumberDenChar[3]=(unsigned char)(FNumberDen[0]>>24);

    //WRITE THE FNumber NUMERATOR
    memcpy (startoftiff+santemp, FNumberNumChar, 4);

    memcpy (startoftiff+santemp+4, FNumberDenChar, 4);
    
    offset+=32;
    ///////////////ENTRY NO 3 :EXPOSURE PROGRAM////////////////////////
    //write ExposureProgram tag
    memcpy (tempExif, ExposureProgramtag, 2);
    tempExif += 2 ;
    //write format
    memcpy (tempExif, ExposureProgramformat, 2);
    tempExif += 2 ;
    //write no of component
    memcpy (tempExif, NcomponentExposureProgram, 4);
    tempExif += 4 ;
    //write orientation mode

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -