Exemplo n.º 1
0
        void data_DataFile(NikonObject sender, NkMAIDFileInfo fileInfo, IntPtr data)
        {
            if (fileInfo.ulStart == 0)
            {
                Debug.Assert(_currentImage == null);

                int            size   = (int)fileInfo.ulTotalLength;
                NikonImageType type   = (NikonImageType)(_currentItemId >> 27);
                int            number = (int)((_currentItemId << 8) >> 8);
                bool           isFragmentOfRawPlusJpeg = (_currentItemId & (1 << 26)) != 0;

                _currentImage = new NikonImage(size, type, number, isFragmentOfRawPlusJpeg);
            }

            Debug.Assert(_currentImage != null);

            int offset = (int)fileInfo.ulStart;
            int length = (int)fileInfo.ulLength;

            _currentImage.CopyFrom(data, offset, length);

            bool complete = (fileInfo.ulTotalLength == fileInfo.ulStart + fileInfo.ulLength);

            if (complete)
            {
                NikonImage image = _currentImage;
                _currentImage = null;

                Scheduler.Callback(new ImageReadyDelegate(OnImageReady), this, image);
            }
        }
Exemplo n.º 2
0
        //
        // Data Callback
        //
        eNkMAIDResult DataProc(
            IntPtr refClient,
            IntPtr pDataInfo,
            IntPtr pData)
        {
            NkMAIDDataInfo info = *((NkMAIDDataInfo *)pDataInfo.ToPointer());

            switch (info.ulType)
            {
            case eNkMAIDDataObjType.kNkMAIDDataObjType_File:
            case eNkMAIDDataObjType.kNkMAIDDataObjType_File | eNkMAIDDataObjType.kNkMAIDDataObjType_Image:
            case eNkMAIDDataObjType.kNkMAIDDataObjType_File | eNkMAIDDataObjType.kNkMAIDDataObjType_Sound:
            case eNkMAIDDataObjType.kNkMAIDDataObjType_File | eNkMAIDDataObjType.kNkMAIDDataObjType_Thumbnail:
            case eNkMAIDDataObjType.kNkMAIDDataObjType_File | eNkMAIDDataObjType.kNkMAIDDataObjType_Video:
                if (DataFile != null)
                {
                    NkMAIDFileInfo fileInfo = *((NkMAIDFileInfo *)pDataInfo.ToPointer());
                    DataFile(this, fileInfo, pData);
                }
                break;

            case eNkMAIDDataObjType.kNkMAIDDataObjType_Thumbnail:
                if (DataImage != null)
                {
                    NkMAIDImageInfo imageInfo = *((NkMAIDImageInfo *)pDataInfo.ToPointer());
                    DataImage(this, imageInfo, pData);
                }
                break;

            case eNkMAIDDataObjType.kNkMAIDDataObjType_Sound:
                if (DataSound != null)
                {
                    NkMAIDSoundInfo soundInfo = *((NkMAIDSoundInfo *)pDataInfo.ToPointer());
                    DataSound(this, soundInfo, pData);
                }
                break;

            default:
                Debug.Print("Unexpected data object type: {0}", info.ulType);
                break;
            }

            return(eNkMAIDResult.kNkMAIDResult_NoError);
        }
Exemplo n.º 3
0
        void data_DataFile(NikonObject sender, NkMAIDFileInfo fileInfo, IntPtr data)
        {
            if (fileInfo.ulStart == 0)
            {
                Debug.Assert(_currentImage == null);

                int size = (int)fileInfo.ulTotalLength;
                NikonImageType type = (NikonImageType)(_currentItemId >> 27);
                int number = (int)((_currentItemId << 8) >> 8);
                bool isFragmentOfRawPlusJpeg = (_currentItemId & (1 << 26)) != 0;

                _currentImage = new NikonImage(size, type, number, isFragmentOfRawPlusJpeg);
            }

            Debug.Assert(_currentImage != null);

            int offset = (int)fileInfo.ulStart;
            int length = (int)fileInfo.ulLength;

            _currentImage.CopyFrom(data, offset, length);

            bool complete = (fileInfo.ulTotalLength == fileInfo.ulStart + fileInfo.ulLength);

            if (complete)
            {
                NikonImage image = _currentImage;
                _currentImage = null;

                Scheduler.Callback(new ImageReadyDelegate(OnImageReady), this, image);
            }
        }