コード例 #1
0
ファイル: tif_next.cs プロジェクト: plynkus/libtiffN
 static bool TIFFInitNeXT(TIFF tif, COMPRESSION scheme)
 {
     tif.tif_decoderow   = NeXTDecode;
     tif.tif_decodestrip = NeXTDecode;
     tif.tif_decodetile  = NeXTDecode;
     return(true);
 }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithModifierProtocols()
        public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithModifierProtocols()
        {
            // given
            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(RAFT_1.implementation())));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(SNAPPY.implementation())));
            _server.handle(new ModifierProtocolRequest(GRATUITOUS_OBFUSCATION.canonicalName(), asSet(ROT13.implementation())));

            // when
            IList <Pair <string, string> > modifierRequest = new IList <Pair <string, string> > {
                Pair.of(SNAPPY.category(), SNAPPY.implementation()), Pair.of(ROT13.category(), ROT13.implementation())
            };

            _server.handle(new SwitchOverRequest(RAFT_1.category(), RAFT_1.implementation(), modifierRequest));

            // then
            verify(_channel).writeAndFlush(InitialMagicMessage.Instance());
            verify(_channel).writeAndFlush(new SwitchOverResponse(SUCCESS));
            ProtocolStack            protocolStack = _server.protocolStackFuture().getNow(null);
            IList <ModifierProtocol> modifiers     = new IList <ModifierProtocol> {
                SNAPPY, ROT13
            };

            assertThat(protocolStack, equalTo(new ProtocolStack(RAFT_1, modifiers)));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithConfiguredModifierProtocols()
        public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithConfiguredModifierProtocols()
        {
            // given
            ISet <string>  requestedVersions         = asSet(TestProtocols_TestModifierProtocols.allVersionsOf(COMPRESSION));
            string         expectedNegotiatedVersion = SNAPPY.implementation();
            IList <string> configuredVersions        = singletonList(expectedNegotiatedVersion);

            IList <ModifierSupportedProtocols> supportedModifierProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, configuredVersions));

            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), supportedModifierProtocols);

            HandshakeServer server = new HandshakeServer(_applicationProtocolRepository, modifierProtocolRepository, _channel);

            server.Handle(InitialMagicMessage.Instance());
            server.Handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(RAFT_1.implementation())));
            server.Handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), requestedVersions));

            // when
            IList <Pair <string, string> > modifierRequest = new IList <Pair <string, string> > {
                Pair.of(SNAPPY.category(), SNAPPY.implementation())
            };

            server.Handle(new SwitchOverRequest(RAFT_1.category(), RAFT_1.implementation(), modifierRequest));

            // then
            verify(_channel).writeAndFlush(InitialMagicMessage.Instance());
            verify(_channel).writeAndFlush(new SwitchOverResponse(SUCCESS));
            ProtocolStack            protocolStack = server.ProtocolStackFuture().getNow(null);
            IList <ModifierProtocol> modifiers     = new IList <ModifierProtocol> {
                SNAPPY
            };

            assertThat(protocolStack, equalTo(new ProtocolStack(RAFT_1, modifiers)));
        }
コード例 #4
0
ファイル: tif_zip.cs プロジェクト: plynkus/libtiffN
        static bool TIFFInitZIP(TIFF tif, COMPRESSION scheme)
        {
            string module = "TIFFInitZIP";

#if DEBUG
            if (scheme != COMPRESSION.DEFLATE && scheme != COMPRESSION.ADOBE_DEFLATE)
            {
                throw new Exception("scheme!=COMPRESSION.DEFLATE&&scheme!=COMPRESSION.ADOBE_DEFLATE");
            }
#endif

            // Merge codec-specific tag information.
            if (!_TIFFMergeFieldInfo(tif, zipFieldInfo))
            {
                TIFFErrorExt(tif.tif_clientdata, module, "Merging Deflate codec-specific tags failed");
                return(false);
            }

            // Allocate state block so tag methods have storage to record values.
            ZIPState sp = null;
            try
            {
                tif.tif_data = sp = new ZIPState();
                sp.stream    = new zlib.z_stream();
            }
            catch
            {
                TIFFErrorExt(tif.tif_clientdata, module, "No space for ZIP state block");
                return(false);
            }

            // Override parent get/set field methods.
            sp.vgetparent = tif.tif_tagmethods.vgetfield;
            tif.tif_tagmethods.vgetfield = ZIPVGetField;           // hook for codec tags
            sp.vsetparent = tif.tif_tagmethods.vsetfield;
            tif.tif_tagmethods.vsetfield = ZIPVSetField;           // hook for codec tags

            // Default values for codec-specific fields
            sp.zipquality = zlib.Z_DEFAULT_COMPRESSION;           // default comp. level
            sp.state      = ZSTATE.None;

            // Install codec methods.
            tif.tif_setupdecode = ZIPSetupDecode;
            tif.tif_predecode   = ZIPPreDecode;
            tif.tif_decoderow   = ZIPDecode;
            tif.tif_decodestrip = ZIPDecode;
            tif.tif_decodetile  = ZIPDecode;
            tif.tif_setupencode = ZIPSetupEncode;
            tif.tif_preencode   = ZIPPreEncode;
            tif.tif_postencode  = ZIPPostEncode;
            tif.tif_encoderow   = ZIPEncode;
            tif.tif_encodestrip = ZIPEncode;
            tif.tif_encodetile  = ZIPEncode;
            tif.tif_cleanup     = ZIPCleanup;

            // Setup predictor setup.
            TIFFPredictorInit(tif);
            return(true);
        }
コード例 #5
0
ファイル: tif_codec.cs プロジェクト: plynkus/libtiffN
 static bool NotConfigured(TIFF tif, COMPRESSION scheme)
 {
     tif.tif_decodestatus = false;
     tif.tif_setupdecode  = _notConfigured;
     tif.tif_encodestatus = false;
     tif.tif_setupencode  = _notConfigured;
     return(false);
 }
コード例 #6
0
ファイル: tif_codec.cs プロジェクト: JoshDullen/libtiffN
        // **************************************************************************
        // *							TIFFIsCODECConfigured()						*
        // **************************************************************************
        // Check whether we have working codec for the specific coding scheme.
        //
        // @return returns true if the codec is configured and working. Otherwise
        // false will be returned.
        public static bool TIFFIsCODECConfigured(COMPRESSION scheme)
        {
            TIFFCodec codec=TIFFFindCODEC(scheme);

            if(codec==null) return false;
            if(codec.init==null) return false;
            return codec.init!=NotConfigured;
        }
コード例 #7
0
ファイル: Compression.cs プロジェクト: flan/media-storage
 /// <summary>
 /// Gets the appropriate compressor-function for the indicated format.
 /// </summary>
 /// <param name='compression'>
 /// The type of compressor to retrieve.
 /// </param>
 /// <exception cref="System.ArgumentException">
 /// An unsupported format was indicated.
 /// </exception>
 internal static System.Func<System.IO.Stream, System.IO.Stream> GetCompressor(COMPRESSION compression)
 {
     if(compression == COMPRESSION.NONE){
         return Compression.NullHandler;
     }else if(compression == COMPRESSION.GZ){
         return Compression.CompressGz;
     }
     throw new System.ArgumentException(compression.ToString() + " is unsupported");
 }
コード例 #8
0
ファイル: tif_zip.cs プロジェクト: JoshDullen/libtiffN
        static bool TIFFInitZIP(TIFF tif, COMPRESSION scheme)
        {
            string module="TIFFInitZIP";

            #if DEBUG
            if(scheme!=COMPRESSION.DEFLATE&&scheme!=COMPRESSION.ADOBE_DEFLATE) throw new Exception("scheme!=COMPRESSION.DEFLATE&&scheme!=COMPRESSION.ADOBE_DEFLATE");
            #endif

            // Merge codec-specific tag information.
            if(!_TIFFMergeFieldInfo(tif, zipFieldInfo))
            {
                TIFFErrorExt(tif.tif_clientdata, module, "Merging Deflate codec-specific tags failed");
                return false;
            }

            // Allocate state block so tag methods have storage to record values.
            ZIPState sp=null;
            try
            {
                tif.tif_data=sp=new ZIPState();
                sp.stream=new zlib.z_stream();
            }
            catch
            {
                TIFFErrorExt(tif.tif_clientdata, module, "No space for ZIP state block");
                return false;
            }

            // Override parent get/set field methods.
            sp.vgetparent=tif.tif_tagmethods.vgetfield;
            tif.tif_tagmethods.vgetfield=ZIPVGetField; // hook for codec tags
            sp.vsetparent=tif.tif_tagmethods.vsetfield;
            tif.tif_tagmethods.vsetfield=ZIPVSetField; // hook for codec tags

            // Default values for codec-specific fields
            sp.zipquality=zlib.Z_DEFAULT_COMPRESSION; // default comp. level
            sp.state=ZSTATE.None;

            // Install codec methods.
            tif.tif_setupdecode=ZIPSetupDecode;
            tif.tif_predecode=ZIPPreDecode;
            tif.tif_decoderow=ZIPDecode;
            tif.tif_decodestrip=ZIPDecode;
            tif.tif_decodetile=ZIPDecode;
            tif.tif_setupencode=ZIPSetupEncode;
            tif.tif_preencode=ZIPPreEncode;
            tif.tif_postencode=ZIPPostEncode;
            tif.tif_encoderow=ZIPEncode;
            tif.tif_encodestrip=ZIPEncode;
            tif.tif_encodetile=ZIPEncode;
            tif.tif_cleanup=ZIPCleanup;

            // Setup predictor setup.
            TIFFPredictorInit(tif);
            return true;
        }
コード例 #9
0
ファイル: tif_compress.cs プロジェクト: plynkus/libtiffN
        public static bool TIFFSetCompressionScheme(TIFF tif, COMPRESSION scheme)
        {
            TIFFCodec c = TIFFFindCODEC((COMPRESSION)scheme);

            TIFFSetDefaultCompressionState(tif);

            // Don't treat an unknown compression scheme as an error.
            // This permits applications to open files with data that
            // the library does not have builtin support for, but which
            // may still be meaningful.
            return(c != null?c.init(tif, scheme):true);
        }
コード例 #10
0
ファイル: tif_dumpmode.cs プロジェクト: plynkus/libtiffN
        // Initialize dump mode.
        static bool TIFFInitDumpMode(TIFF tif, COMPRESSION scheme)
        {
            tif.tif_decoderow   = DumpModeDecode;
            tif.tif_decodestrip = DumpModeDecode;
            tif.tif_decodetile  = DumpModeDecode;
            tif.tif_encoderow   = DumpModeEncode;
            tif.tif_encodestrip = DumpModeEncode;
            tif.tif_encodetile  = DumpModeEncode;
            tif.tif_seek        = DumpModeSeek;

            return(true);
        }
コード例 #11
0
ファイル: tif_compress.cs プロジェクト: plynkus/libtiffN
 public static TIFFCodec TIFFRegisterCODEC(COMPRESSION scheme, string name, TIFFInitMethod init)
 {
     try
     {
         registeredCODECS.Add(new TIFFCodec(name, scheme, init));
     }
     catch
     {
         TIFFError("TIFFRegisterCODEC", "No space to register compression scheme {0}", name);
         return(null);
     }
     return(registeredCODECS[registeredCODECS.Count - 1]);
 }
コード例 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCloseConnectionForGivenModifierProtocol()
        public void shouldNotCloseConnectionForGivenModifierProtocol()
        {
            // given
            ISet <string> versions = asSet(SNAPPY.implementation(), LZO.implementation(), LZ4.implementation());

            _server.handle(InitialMagicMessage.Instance());

            // when
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), versions));

            // then
            AssertUnfinished();
        }
コード例 #13
0
ファイル: tif_packbits.cs プロジェクト: plynkus/libtiffN
 static bool TIFFInitPackBits(TIFF tif, COMPRESSION scheme)
 {
     //tif.tif_predecode=PackBitsPreDecode;
     tif.tif_decoderow   = PackBitsDecode;
     tif.tif_decodestrip = PackBitsDecode;
     tif.tif_decodetile  = PackBitsDecode;
     tif.tif_preencode   = PackBitsPreEncode;
     tif.tif_postencode  = PackBitsPostEncode;
     tif.tif_encoderow   = PackBitsEncode;
     tif.tif_encodestrip = PackBitsEncodeChunk;
     tif.tif_encodetile  = PackBitsEncodeChunk;
     return(true);
 }
コード例 #14
0
ファイル: tif_compress.cs プロジェクト: JoshDullen/libtiffN
 public static TIFFCodec TIFFRegisterCODEC(COMPRESSION scheme, string name, TIFFInitMethod init)
 {
     try
     {
         registeredCODECS.Add(new TIFFCodec(name, scheme, init));
     }
     catch
     {
         TIFFError("TIFFRegisterCODEC", "No space to register compression scheme {0}", name);
         return null;
     }
     return registeredCODECS[registeredCODECS.Count-1];
 }
コード例 #15
0
ファイル: tif_codec.cs プロジェクト: plynkus/libtiffN
        // **************************************************************************
        // *							TIFFIsCODECConfigured()						*
        // **************************************************************************

        // Check whether we have working codec for the specific coding scheme.
        //
        // @return returns true if the codec is configured and working. Otherwise
        // false will be returned.
        public static bool TIFFIsCODECConfigured(COMPRESSION scheme)
        {
            TIFFCodec codec = TIFFFindCODEC(scheme);

            if (codec == null)
            {
                return(false);
            }
            if (codec.init == null)
            {
                return(false);
            }
            return(codec.init != NotConfigured);
        }
コード例 #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendModifierProtocolResponseForGivenProtocol()
        public void shouldSendModifierProtocolResponseForGivenProtocol()
        {
            // given
            ISet <string> versions = asSet(TestProtocols_TestModifierProtocols.allVersionsOf(COMPRESSION));

            _server.handle(InitialMagicMessage.Instance());

            // when
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), versions));

            // then
            ModifierProtocol expected = TestProtocols_TestModifierProtocols.latest(COMPRESSION);

            verify(_channel).writeAndFlush(new ModifierProtocolResponse(SUCCESS, expected.category(), expected.implementation()));
        }
コード例 #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailModifierProtocolResponseForUnknownVersion()
        public void shouldSendFailModifierProtocolResponseForUnknownVersion()
        {
            // given
            ISet <string> versions = asSet("Not a real protocol");

            _server.handle(InitialMagicMessage.Instance());

            // when
            string protocolName = COMPRESSION.canonicalName();

            _server.handle(new ModifierProtocolRequest(protocolName, versions));

            // then
            verify(_channel).writeAndFlush(new ModifierProtocolResponse(FAILURE, protocolName, ""));
        }
コード例 #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCloseConnectionIfUnknownModifierProtocolVersion()
        public void shouldNotCloseConnectionIfUnknownModifierProtocolVersion()
        {
            // given
            ISet <string> versions = asSet("not a real algorithm");

            _server.handle(InitialMagicMessage.Instance());

            // when
            string protocolName = COMPRESSION.canonicalName();

            _server.handle(new ModifierProtocolRequest(protocolName, versions));

            // then
            AssertUnfinished();
        }
コード例 #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersByVersionFromNegotiatedModifiedProtocol()
        public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersByVersionFromNegotiatedModifiedProtocol()
        {
            // given
            int version = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(version)));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(SNAPPY.implementation())));

            // when
            _server.handle(new SwitchOverRequest(RAFT_1.category(), version, new IList <Pair <string, string> > {
                Pair.of(COMPRESSION.canonicalName(), LZ4.implementation())
            }));

            // then
            AssertExceptionallyCompletedProtocolStackFuture();
        }
コード例 #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersByNameFromNegotiatedModifiedProtocol()
        public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersByNameFromNegotiatedModifiedProtocol()
        {
            // given
            string modifierVersion    = ROT13.implementation();
            int    applicationVersion = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(applicationVersion)));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(modifierVersion)));

            // when
            _server.handle(new SwitchOverRequest(RAFT.canonicalName(), applicationVersion, new IList <Pair <string, string> > {
                Pair.of(GRATUITOUS_OBFUSCATION.canonicalName(), modifierVersion)
            }));

            // then
            AssertExceptionallyCompletedProtocolStackFuture();
        }
コード例 #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackIfSwitchOverChangesOrderOfModifierProtocols()
        public void shouldExceptionallyCompleteProtocolStackIfSwitchOverChangesOrderOfModifierProtocols()
        {
            // given
            int version = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(version)));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(SNAPPY.implementation())));
            _server.handle(new ModifierProtocolRequest(GRATUITOUS_OBFUSCATION.canonicalName(), asSet(ROT13.implementation())));

            // when
            _server.handle(new SwitchOverRequest(RAFT.canonicalName(), version, new IList <Pair <string, string> > {
                Pair.of(GRATUITOUS_OBFUSCATION.canonicalName(), ROT13.implementation()), Pair.of(COMPRESSION.canonicalName(), SNAPPY.implementation())
            }));

            // then
            AssertExceptionallyCompletedProtocolStackFuture();
        }
コード例 #22
0
ファイル: tif_compress.cs プロジェクト: plynkus/libtiffN
 public static TIFFCodec TIFFFindCODEC(COMPRESSION scheme)
 {
     foreach (TIFFCodec c in registeredCODECS)
     {
         if (c.scheme == scheme)
         {
             return(c);
         }
     }
     foreach (TIFFCodec c in TIFFBuiltinCODECS)
     {
         if (c.scheme == scheme)
         {
             return(c);
         }
     }
     return(null);
 }
コード例 #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverDiffersByVersionFromNegotiatedModifierProtocol()
        public void shouldSendFailureIfSwitchOverDiffersByVersionFromNegotiatedModifierProtocol()
        {
            // given
            int version = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(version)));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(SNAPPY.implementation())));

            // when
            _server.handle(new SwitchOverRequest(RAFT_1.category(), version, new IList <Pair <string, string> > {
                Pair.of(COMPRESSION.canonicalName(), LZ4.implementation())
            }));

            // then
            InOrder inOrder = Mockito.inOrder(_channel);

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
コード例 #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverChangesOrderOfModifierProtocols()
        public void shouldSendFailureIfSwitchOverChangesOrderOfModifierProtocols()
        {
            // given
            int version = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(version)));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(SNAPPY.implementation())));
            _server.handle(new ModifierProtocolRequest(GRATUITOUS_OBFUSCATION.canonicalName(), asSet(ROT13.implementation())));

            // when
            _server.handle(new SwitchOverRequest(RAFT.canonicalName(), version, new IList <Pair <string, string> > {
                Pair.of(GRATUITOUS_OBFUSCATION.canonicalName(), ROT13.implementation()), Pair.of(COMPRESSION.canonicalName(), SNAPPY.implementation())
            }));

            // then
            InOrder inOrder = Mockito.inOrder(_channel);

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
コード例 #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverDiffersByNameFromNegotiatedModifierProtocol()
        public void shouldSendFailureIfSwitchOverDiffersByNameFromNegotiatedModifierProtocol()
        {
            // given
            string modifierVersion    = ROT13.implementation();
            int    applicationVersion = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(applicationVersion)));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(modifierVersion)));

            // when
            _server.handle(new SwitchOverRequest(RAFT.canonicalName(), applicationVersion, new IList <Pair <string, string> > {
                Pair.of(GRATUITOUS_OBFUSCATION.canonicalName(), modifierVersion)
            }));

            // then
            InOrder inOrder = Mockito.inOrder(_channel);

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
コード例 #26
0
 public TIFFCodec(string name, COMPRESSION scheme, TIFFInitMethod init)
 {
     this.name   = name;
     this.scheme = scheme;
     this.init   = init;
 }
コード例 #27
0
ファイル: tif_jpeg.cs プロジェクト: JoshDullen/libtiffN
        static bool TIFFInitJPEG(TIFF tif, COMPRESSION scheme)
        {
            #if DEBUG
            if(scheme!=COMPRESSION.JPEG) throw new Exception("scheme!=COMPRESSION.JPEG");
            #endif

            // Merge codec-specific tag information.
            if(!_TIFFMergeFieldInfo(tif, jpegFieldInfo))
            {
                TIFFErrorExt(tif.tif_clientdata, "TIFFInitJPEG", "Merging JPEG codec-specific tags failed");
                return false;
            }

            // Allocate state block so tag methods have storage to record values.
            JPEGState sp=null;
            try
            {
                tif.tif_data=sp=new JPEGState();
            }
            catch
            {
                TIFFErrorExt(tif.tif_clientdata, "TIFFInitJPEG", "No space for JPEG state block");
                return false;
            }

            sp.tif=tif; // back link

            // Override parent get/set field methods.
            sp.vgetparent=tif.tif_tagmethods.vgetfield;
            tif.tif_tagmethods.vgetfield=JPEGVGetField;	// hook for codec tags
            sp.vsetparent=tif.tif_tagmethods.vsetfield;
            tif.tif_tagmethods.vsetfield=JPEGVSetField;	// hook for codec tags
            sp.printdir=tif.tif_tagmethods.printdir;
            tif.tif_tagmethods.printdir=JPEGPrintDir;	// hook for codec tags

            // Default values for codec-specific fields
            sp.jpegtables=null;
            sp.jpegtables_length=0;
            sp.jpegquality=75;			// Default IJG quality
            sp.jpegcolormode=JPEGCOLORMODE.RAW;
            sp.jpegtablesmode=JPEGTABLESMODE.QUANT|JPEGTABLESMODE.HUFF;

            sp.recvparams=0;
            sp.subaddress=null;
            sp.faxdcs=null;

            sp.ycbcrsampling_fetched=false;

            // Install codec methods.
            tif.tif_setupdecode=JPEGSetupDecode;
            tif.tif_predecode=JPEGPreDecode;
            tif.tif_decoderow=JPEGDecode;
            tif.tif_decodestrip=JPEGDecode;
            tif.tif_decodetile=JPEGDecode;
            tif.tif_setupencode=JPEGSetupEncode;
            tif.tif_preencode=JPEGPreEncode;
            tif.tif_postencode=JPEGPostEncode;
            tif.tif_encoderow=JPEGEncode;
            tif.tif_encodestrip=JPEGEncode;
            tif.tif_encodetile=JPEGEncode;
            tif.tif_cleanup=JPEGCleanup;
            sp.defsparent=tif.tif_defstripsize;
            tif.tif_defstripsize=JPEGDefaultStripSize;
            sp.deftparent=tif.tif_deftilesize;
            tif.tif_deftilesize=JPEGDefaultTileSize;
            tif.tif_flags|=TIF_FLAGS.TIFF_NOBITREV; // no bit reversal, please

            sp.cinfo_initialized=false;

            // Create a JPEGTables field if no directory has yet been created.
            // We do this just to ensure that sufficient space is reserved for
            // the JPEGTables field. It will be properly created the right
            // size later.
            if(tif.tif_diroff==0)
            {
                uint SIZE_OF_JPEGTABLES=2000;

                // The following line assumes incorrectly that all JPEG-in-TIFF files will have
                // a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags to be written
                // when the JPEG data is placed with TIFFWriteRawStrip.  The field bit should be
                // set, anyway, later when actual JPEGTABLES header is generated, so removing it
                // here hopefully is harmless.
                //TIFFSetFieldBit(tif, FIELD.JPEG_JPEGTABLES);

                sp.jpegtables_length=SIZE_OF_JPEGTABLES;
                sp.jpegtables=new byte[sp.jpegtables_length];
            }

            // Mark the TIFFTAG.YCBCRSAMPLES as present even if it is not
            // see: JPEGFixupTestSubsampling().
            TIFFSetFieldBit(tif, FIELD.YCBCRSUBSAMPLING);

            return true;
        }
コード例 #28
0
ファイル: Client.cs プロジェクト: flan/media-storage
        /// <summary>
        /// Stores the content of <c>data</c> on the server, returning information about how to access it later.
        /// </summary>
        /// <param name='data'>
        /// The content to be stored.
        /// </param>
        /// <param name='mime'>
        /// The MIME-type of the content being stored.
        /// </param>
        /// <param name='family'>
        /// The case-sensitive, arbitrary family to which the data belongs; defaults to <c>null</c>, for the
        /// generic family.
        /// </param>
        /// <param name='compression'>
        /// The type of compression to apply when storing the file; defaults to <c>COMPRESSION.NONE</c>
        /// </param>
        /// <param name='compress_on_server'>
        /// Indicates whether the client should require the server to perform compression, rather than trying
        /// locally; defaults to <c>false</c>.
        /// </param>
        /// <param name='deletion_policy'>
        /// May either be <c>null</c>, the default, which means the file is never removed or a <see cref="Structures.DeletionPolicy"/>
        /// instance.
        /// </param>
        /// <param name='compression_policy'>
        /// May either be <c>null</c>, the default, which means the file is never compressed or a <see cref="Structures.CompressionPolicy"/>
        /// instance.
        /// </param>
        /// <param name='meta'>
        /// Any additional metadata with which to tag the file; defaults to <c>null</c>, meaning no metadata.
        /// </param>
        /// <param name='uid'>
        /// If not implementing a proxy, leave this value at its default of <c>null</c> to have an identifier auto-generated or pick something that
        /// has no chance of colliding with a UUID(1).
        /// </param>
        /// <param name='keys'>
        /// In general, you should not need to specify anything, leaving it at <c>null</c>, but if you have a homogenous
        /// or anonymous access policy, a <see cref="Structures.Keys"/> instance may be used, with either key set to an arbitrary string or
        /// <c>null</c>, with <c>null</c> granting anonymous access to the corresponding facet.
        ///
        /// Either element may be omitted to have it generated by the server.
        /// </param>
        /// <param name='timeout'>
        /// The number of seconds to wait for a response; defaults to 10.
        /// </param>
        /// <exception cref="System.Exception">
        /// Some unknown problem occurred.
        /// </exception>
        /// <exception cref="Exceptions.ProtocolError">
        /// A problem occurred related to the transport protocol.
        /// </exception>
        /// <exception cref="Exceptions.UrlError">
        /// A problem occurred related to the network environment.
        /// </exception>
        public Structures.Storage Put(
         System.IO.Stream data, string mime, string family=null,
         COMPRESSION compression=COMPRESSION.NONE, bool compress_on_server=false,
         Structures.DeletionPolicy deletion_policy=null,
         Structures.CompressionPolicy compression_policy=null,
         System.Collections.Generic.IDictionary<string, object> meta=null,
         string uid=null, Structures.Keys keys=null,
         float timeout=10.0f
        )
        {
            Jayrock.Json.JsonObject put = new Jayrock.Json.JsonObject();
            put.Add("uid", uid);
            put.Add("keys", keys);
            put.Add("meta", meta);

            Jayrock.Json.JsonObject physical = new Jayrock.Json.JsonObject();
            physical.Add("family", family);

            Jayrock.Json.JsonObject format = new Jayrock.Json.JsonObject();
            format.Add("mime", mime);
            format.Add("comp", compression != COMPRESSION.NONE ? compression.ToString().ToLower() : null);
            physical.Add("format", format);
            put.Add("physical", physical);

            Jayrock.Json.JsonObject policy = new Jayrock.Json.JsonObject();
            policy.Add("delete", deletion_policy != null ? deletion_policy.ToDictionary() : null);
            policy.Add("compress", compression_policy != null ? compression_policy.ToDictionary() : null);
            put.Add("policy", policy);

            System.Collections.Generic.Dictionary<string, string> headers = new System.Collections.Generic.Dictionary<string, string>();
            if(!compress_on_server){
                try{
                    data = Libraries.Compression.GetCompressor(compression).Invoke(data);
                    headers.Add(Libraries.Communication.HEADER_COMPRESS_ON_SERVER, Libraries.Communication.HEADER_COMPRESS_ON_SERVER_FALSE);
                }catch(System.Exception){
                    headers.Add(Libraries.Communication.HEADER_COMPRESS_ON_SERVER, Libraries.Communication.HEADER_COMPRESS_ON_SERVER_TRUE);
                }
            }else{
                headers.Add(Libraries.Communication.HEADER_COMPRESS_ON_SERVER, Libraries.Communication.HEADER_COMPRESS_ON_SERVER_TRUE);
            }

            System.Net.HttpWebRequest request = Libraries.Communication.AssembleRequest(this.server.GetHost() + Libraries.Communication.SERVER_PUT, put, headers:headers, data:data);
            return new Structures.Storage(Libraries.Communication.SendRequest(request, timeout:timeout).ToDictionary());
        }
コード例 #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters public static java.util.Collection<Parameters> data()
        public static ICollection <Parameters> Data()
        {
            // Application protocols
            ApplicationSupportedProtocols allRaft          = new ApplicationSupportedProtocols(RAFT, TestProtocols_TestApplicationProtocols.listVersionsOf(RAFT));
            ApplicationSupportedProtocols raft1            = new ApplicationSupportedProtocols(RAFT, singletonList(RAFT_1.implementation()));
            ApplicationSupportedProtocols allRaftByDefault = new ApplicationSupportedProtocols(RAFT, emptyList());

            // Modifier protocols
            ICollection <ModifierSupportedProtocols> allModifiers = asList(new ModifierSupportedProtocols(COMPRESSION, TestProtocols_TestModifierProtocols.listVersionsOf(COMPRESSION)), new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, TestProtocols_TestModifierProtocols.listVersionsOf(GRATUITOUS_OBFUSCATION))
                                                                           );
            ICollection <ModifierSupportedProtocols> allCompressionModifiers          = singletonList(new ModifierSupportedProtocols(COMPRESSION, TestProtocols_TestModifierProtocols.listVersionsOf(COMPRESSION)));
            ICollection <ModifierSupportedProtocols> allObfuscationModifiers          = singletonList(new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, TestProtocols_TestModifierProtocols.listVersionsOf(GRATUITOUS_OBFUSCATION)));
            ICollection <ModifierSupportedProtocols> allCompressionModifiersByDefault = singletonList(new ModifierSupportedProtocols(COMPRESSION, emptyList()));

            IList <ModifierSupportedProtocols> onlyLzoCompressionModifiers    = singletonList(new ModifierSupportedProtocols(COMPRESSION, singletonList(LZO.implementation())));
            IList <ModifierSupportedProtocols> onlySnappyCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, singletonList(SNAPPY.implementation())));

            ICollection <ModifierSupportedProtocols> noModifiers = emptyList();

            // Ordered modifier protocols
            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), allModifiers);

            string[] lzoFirstVersions = new string[] { LZO.implementation(), LZ4.implementation(), SNAPPY.implementation() };
            IList <ModifierSupportedProtocols> lzoFirstCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                lzoFirstVersions
            }));
            Protocol_ModifierProtocol preferredLzoFirstCompressionModifier = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet(lzoFirstVersions)).get();

            string[] snappyFirstVersions = new string[] { SNAPPY.implementation(), LZ4.implementation(), LZO.implementation() };
            IList <ModifierSupportedProtocols> snappyFirstCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                snappyFirstVersions
            }));
            Protocol_ModifierProtocol preferredSnappyFirstCompressionModifier = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet(snappyFirstVersions)).get();

            return(asList(new Parameters(allRaft, allRaft, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaftByDefault, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaftByDefault, allRaft, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, raft1, allModifiers, allModifiers, RAFT_1, new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(raft1, allRaft, allModifiers, allModifiers, RAFT_1, new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allCompressionModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allModifiers, allCompressionModifiersByDefault, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allCompressionModifiersByDefault, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allModifiers, allObfuscationModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allObfuscationModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allModifiers, lzoFirstCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { LZO }), new Parameters(allRaft, allRaft, lzoFirstCompressionModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { preferredLzoFirstCompressionModifier }), new Parameters(allRaft, allRaft, allModifiers, snappyFirstCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { SNAPPY }), new Parameters(allRaft, allRaft, snappyFirstCompressionModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { preferredSnappyFirstCompressionModifier }), new Parameters(allRaft, allRaft, allModifiers, onlyLzoCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.LZO }), new Parameters(allRaft, allRaft, onlyLzoCompressionModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.LZO }), new Parameters(allRaft, allRaft, onlySnappyCompressionModifiers, onlyLzoCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, onlyLzoCompressionModifiers, onlySnappyCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, allModifiers, noModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, noModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {})
                          ));
        }
コード例 #30
0
ファイル: Description.cs プロジェクト: flan/media-storage
 /// <summary>
 /// Extracts format description information from the server's response.
 /// </summary>
 /// <param name='format'>
 /// The structure to be dissected.
 /// </param>
 internal DescriptionPhysicalFormat(System.Collections.Generic.IDictionary<string, object> format)
 {
     this.Mime = (string)format["mime"];
     if(format.ContainsKey("comp")){
         this.Compression = Libraries.Compression.ResolveCompressionFormat((string)format["comp"]);
     }
 }
コード例 #31
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnModifierProtocolOfSingleConfiguredVersionIfOthersRequested()
        public virtual void ShouldReturnModifierProtocolOfSingleConfiguredVersionIfOthersRequested()
        {
            // given
            IList <ModifierSupportedProtocols> supportedProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                LZO.implementation()
            }));
            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), supportedProtocols);
            // when
            Optional <Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocol> modifierProtocol = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet(TestProtocols_TestModifierProtocols.allVersionsOf(COMPRESSION)));

            // then
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat(modifierProtocol.map(Protocol::implementation), OptionalMatchers.contains(LZO.implementation()));
        }
コード例 #32
0
ファイル: tif_fax3.cs プロジェクト: JoshDullen/libtiffN
        static bool TIFFInitCCITTFax3(TIFF tif, COMPRESSION scheme)
        {
            if(InitCCITTFax3(tif))
            {
                // Merge codec-specific tag information.
                if(!_TIFFMergeFieldInfo(tif, fax3FieldInfo))
                {
                    TIFFErrorExt(tif.tif_clientdata, "TIFFInitCCITTFax3", "Merging CCITT Fax 3 codec-specific tags failed");
                    return false;
                }

                // The default format is Class/F-style w/o RTC.
                return TIFFSetField(tif, TIFFTAG.FAXMODE, FAXMODE.CLASSF);
            }

            return true;
        }
コード例 #33
0
ファイル: tif_fax3.cs プロジェクト: JoshDullen/libtiffN
        static bool TIFFInitCCITTRLEW(TIFF tif, COMPRESSION scheme)
        {
            if(InitCCITTFax3(tif))
            { // reuse G3 support
                tif.tif_decoderow=Fax3DecodeRLE;
                tif.tif_decodestrip=Fax3DecodeRLE;
                tif.tif_decodetile=Fax3DecodeRLE;
                // Suppress RTC+EOLs when encoding and word-align data.
                return TIFFSetField(tif, TIFFTAG.FAXMODE, FAXMODE.NORTC|FAXMODE.NOEOL|FAXMODE.WORDALIGN);
            }

            return false;
        }
コード例 #34
0
ファイル: tif_compress.cs プロジェクト: JoshDullen/libtiffN
 public static TIFFCodec TIFFFindCODEC(COMPRESSION scheme)
 {
     foreach(TIFFCodec c in registeredCODECS) if(c.scheme==scheme) return c;
     foreach(TIFFCodec c in TIFFBuiltinCODECS) if(c.scheme==scheme) return c;
     return null;
 }
コード例 #35
0
ファイル: tif_thunder.cs プロジェクト: JoshDullen/libtiffN
 static bool TIFFInitThunderScan(TIFF tif, COMPRESSION scheme)
 {
     tif.tif_decoderow=ThunderDecodeRow;
     tif.tif_decodestrip=ThunderDecodeRow;
     return true;
 }
コード例 #36
0
ファイル: tif_codec.cs プロジェクト: JoshDullen/libtiffN
 static bool NotConfigured(TIFF tif, COMPRESSION scheme)
 {
     tif.tif_decodestatus=false;
     tif.tif_setupdecode=_notConfigured;
     tif.tif_encodestatus=false;
     tif.tif_setupencode=_notConfigured;
     return false;
 }
コード例 #37
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompareModifierProtocolsByListOrder()
        public virtual void ShouldCompareModifierProtocolsByListOrder()
        {
            IList <ModifierSupportedProtocols> supportedProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                LZO.implementation(), SNAPPY.implementation(), LZ4.implementation()
            }));

            IComparer <Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocol> comparator = ModifierProtocolRepository.GetModifierProtocolComparator(supportedProtocols).apply(COMPRESSION.canonicalName());

            assertThat(comparator.Compare(LZO, TestProtocols_TestModifierProtocols.Snappy), Matchers.greaterThan(0));
            assertThat(comparator.Compare(TestProtocols_TestModifierProtocols.Snappy, TestProtocols_TestModifierProtocols.Lz4), Matchers.greaterThan(0));
        }
コード例 #38
0
ファイル: tif_lzw.cs プロジェクト: JoshDullen/libtiffN
		static bool TIFFInitLZW(TIFF tif, COMPRESSION scheme)
		{
#if DEBUG
			if(scheme!=COMPRESSION.LZW) throw new Exception("scheme!=COMPRESSION.LZW");
#endif
			// Allocate state block so tag methods have storage to record values.
			LZWCodecState sp=null;
			try
			{
				tif.tif_data=sp=new LZWCodecState();
			}
			catch
			{
				TIFFErrorExt(tif.tif_clientdata, "TIFFInitLZW", "No space for LZW state block");
				return false;
			}

			sp.dec_codetab=null;
			sp.dec_decode=null;
			sp.enc_hashtab=null;
			sp.rw_mode=tif.tif_mode;

			// Install codec methods.
			tif.tif_setupdecode=LZWSetupDecode;
			tif.tif_predecode=LZWPreDecode;
			tif.tif_decoderow=LZWDecode;
			tif.tif_decodestrip=LZWDecode;
			tif.tif_decodetile=LZWDecode;
			tif.tif_setupencode=LZWSetupEncode;
			tif.tif_preencode=LZWPreEncode;
			tif.tif_postencode=LZWPostEncode;
			tif.tif_encoderow=LZWEncode;
			tif.tif_encodestrip=LZWEncode;
			tif.tif_encodetile=LZWEncode;
			tif.tif_cleanup=LZWCleanup;

			// Setup predictor setup.
			TIFFPredictorInit(tif);
			return true;
		}
コード例 #39
0
ファイル: StorageProxy.cs プロジェクト: flan/media-storage
        /// <summary>
        /// Stores the content of <c>data</c> in the proxy's buffers, returning information about how to access it later.
        ///
        /// It is important to note that the data is NOT actually stored when this pointer is returned,
        /// but rather that the pointer will be valid at some point in the future (typically very soon,
        /// but not within a predictable timeframe).
        /// </summary>
        /// <param name='data'>
        /// The path to the content to be stored.
        /// </param>
        /// <param name='mime'>
        /// The MIME-type of the content being stored.
        /// </param>
        /// <param name='family'>
        /// The case-sensitive, arbitrary family to which the data belongs; defaults to <c>null</c>, for the
        /// generic family.
        /// </param>
        /// <param name='compression'>
        /// The type of compression to apply when storing the file; defaults to <c>COMPRESSION.NONE</c>
        /// </param>
        /// <param name='compress_on_server'>
        /// Indicates whether the proxy should require the server to perform compression, rather than trying
        /// locally; defaults to <c>false</c>.
        /// </param>
        /// <param name='deletion_policy'>
        /// May either be <c>null</c>, the default, which means the file is never removed or a <see cref="Structures.DeletionPolicy"/>
        /// instance.
        /// </param>
        /// <param name='compression_policy'>
        /// May either be <c>null</c>, the default, which means the file is never compressed or a <see cref="Structures.CompressionPolicy"/>
        /// instance.
        /// </param>
        /// <param name='meta'>
        /// Any additional metadata with which to tag the file; defaults to <c>null</c>, meaning no metadata.
        /// </param>
        /// <param name='uid'>
        /// If not implementing a proxy, leave this value at its default of <c>null</c> to have an identifier auto-generated or pick something that
        /// has no chance of colliding with a UUID(1).
        /// </param>
        /// <param name='keys'>
        /// In general, you should not need to specify anything, leaving it at <c>null</c>, but if you have a homogenous
        /// or anonymous access policy, a <see cref="Structures.Keys"/> instance may be used, with either key set to an arbitrary string or
        /// <c>null</c>, with <c>null</c> granting anonymous access to the corresponding facet.
        ///
        /// Either element may be omitted to have it generated by the server.
        /// </param>
        /// <param name='timeout'>
        /// The number of seconds to wait for a response; defaults to 3.
        /// </param>
        /// <exception cref="System.Exception">
        /// Some unknown problem occurred.
        /// </exception>
        /// <exception cref="Exceptions.ProtocolError">
        /// A problem occurred related to the transport protocol.
        /// </exception>
        /// <exception cref="Exceptions.UrlError">
        /// A problem occurred related to the network environment.
        /// </exception>
        public Structures.Storage Put(
         string data, string mime, string family=null,
         COMPRESSION compression=COMPRESSION.NONE, bool compress_on_server=false,
         Structures.DeletionPolicy deletion_policy=null,
         Structures.CompressionPolicy compression_policy=null,
         COMPRESSION compression_policy_format=COMPRESSION.NONE,
         System.Collections.Generic.IDictionary<string, object> meta=null,
         string uid=null, Structures.Keys keys=null,
         float timeout=3.0f
        )
        {
            Jayrock.Json.JsonObject put = new Jayrock.Json.JsonObject();
            put.Add("uid", uid);
            put.Add("keys", keys);
            put.Add("meta", meta);

            Jayrock.Json.JsonObject physical = new Jayrock.Json.JsonObject();
            physical.Add("family", family);

            Jayrock.Json.JsonObject format = new Jayrock.Json.JsonObject();
            format.Add("mime", mime);
            format.Add("comp", compression != COMPRESSION.NONE ? compression.ToString().ToLower() : null);
            physical.Add("format", format);
            put.Add("physical", physical);

            Jayrock.Json.JsonObject policy = new Jayrock.Json.JsonObject();
            policy.Add("delete", deletion_policy != null ? deletion_policy.ToDictionary() : null);
            policy.Add("compress", compression_policy != null ? compression_policy.ToDictionary() : null);
            put.Add("policy", policy);

            Jayrock.Json.JsonObject proxy = new Jayrock.Json.JsonObject();
            proxy.Add("server", this.server.ToDictionary());
            proxy.Add("data", data);
            put.Add("proxy", proxy);

            System.Net.HttpWebRequest request = Libraries.Communication.AssembleRequest(this.proxy + Libraries.Communication.SERVER_PUT, put);
            return new Structures.Storage(Libraries.Communication.SendRequest(request, timeout:timeout).ToDictionary());
        }
コード例 #40
0
ファイル: tiffio.cs プロジェクト: JoshDullen/libtiffN
 public TIFFCodec(string name, COMPRESSION scheme, TIFFInitMethod init)
 {
     this.name=name;
     this.scheme=scheme;
     this.init=init;
 }
コード例 #41
0
ファイル: tif_fax3.cs プロジェクト: JoshDullen/libtiffN
        static bool TIFFInitCCITTFax4(TIFF tif, COMPRESSION scheme)
        {
            if(InitCCITTFax3(tif))
            { // reuse G3 support
                // Merge codec-specific tag information.
                if(!_TIFFMergeFieldInfo(tif, fax4FieldInfo))
                {
                    TIFFErrorExt(tif.tif_clientdata, "TIFFInitCCITTFax4", "Merging CCITT Fax 4 codec-specific tags failed");
                    return false;
                }

                tif.tif_decoderow=Fax4Decode;
                tif.tif_decodestrip=Fax4Decode;
                tif.tif_decodetile=Fax4Decode;
                tif.tif_encoderow=Fax4Encode;
                tif.tif_encodestrip=Fax4Encode;
                tif.tif_encodetile=Fax4Encode;
                tif.tif_postencode=Fax4PostEncode;

                // Suppress RTC at the end of each strip.
                return TIFFSetField(tif, TIFFTAG.FAXMODE, FAXMODE.NORTC);
            }

            return false;
        }
コード例 #42
0
ファイル: tif_compress.cs プロジェクト: JoshDullen/libtiffN
        public static bool TIFFSetCompressionScheme(TIFF tif, COMPRESSION scheme)
        {
            TIFFCodec c=TIFFFindCODEC((COMPRESSION)scheme);

            TIFFSetDefaultCompressionState(tif);

            // Don't treat an unknown compression scheme as an error.
            // This permits applications to open files with data that
            // the library does not have builtin support for, but which
            // may still be meaningful.
            return (c!=null?c.init(tif, scheme):true);
        }
コード例 #43
0
ファイル: tif_thunder.cs プロジェクト: plynkus/libtiffN
 static bool TIFFInitThunderScan(TIFF tif, COMPRESSION scheme)
 {
     tif.tif_decoderow   = ThunderDecodeRow;
     tif.tif_decodestrip = ThunderDecodeRow;
     return(true);
 }
コード例 #44
0
ファイル: tif_next.cs プロジェクト: JoshDullen/libtiffN
 static bool TIFFInitNeXT(TIFF tif, COMPRESSION scheme)
 {
     tif.tif_decoderow=NeXTDecode;
     tif.tif_decodestrip=NeXTDecode;
     tif.tif_decodetile=NeXTDecode;
     return true;
 }
コード例 #45
0
ファイル: Policy.cs プロジェクト: flan/media-storage
 /// <summary>
 /// Extracts policy information from the server's response.
 /// </summary>
 /// <param name='policy'>
 /// The structure to be dissected.
 /// </param>
 internal CompressionPolicy(System.Collections.Generic.IDictionary<string, object> policy)
     : base(policy)
 {
     this.Format = Libraries.Compression.ResolveCompressionFormat((string)policy ["comp"]);
 }
コード例 #46
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnModifierProtocolOfFirstConfiguredVersionRequestedAndSupported()
        public virtual void ShouldReturnModifierProtocolOfFirstConfiguredVersionRequestedAndSupported()
        {
            // given
            IList <ModifierSupportedProtocols> supportedProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                LZO.implementation(), SNAPPY.implementation(), LZ4.implementation()
            }), new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, new IList <string> {
                NAME_CLASH.implementation()
            }));
            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), supportedProtocols);
            // when
            Optional <Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocol> modifierProtocol = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet("bzip2", SNAPPY.implementation(), LZ4.implementation(), LZO.implementation(), "fast_lz"));

            // then
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat(modifierProtocol.map(Protocol::implementation), OptionalMatchers.contains(LZO.implementation()));
        }
コード例 #47
0
ファイル: tif_dir.cs プロジェクト: JoshDullen/libtiffN
        public void Clear()
        {
            td_fieldsset=new uint[libtiff.FIELD_SETLONGS];
            td_imagewidth=td_imagelength=td_imagedepth=0;
            td_tilewidth=td_tilelength=td_tiledepth=0;
            td_subfiletype=0;
            td_bitspersample=0;
            td_sampleformat=0;
            td_compression=0;
            td_photometric=0;
            td_threshholding=0;
            td_fillorder=0;
            td_orientation=0;
            td_samplesperpixel=0;
            td_rowsperstrip=0;
            td_minsamplevalue=td_maxsamplevalue=0;
            td_sminsamplevalue=td_smaxsamplevalue=0;
            td_xresolution=td_yresolution=0;
            td_resolutionunit=0;
            td_planarconfig=0;
            td_xposition=td_yposition=0;
            td_pagenumber=new ushort[2];
            td_colormap=new ushort[3][];
            td_halftonehints=new ushort[2];
            td_extrasamples=0;
            td_sampleinfo=null;

            td_stripsperimage=0;
            td_nstrips=0;				// size of offset & bytecount arrays
            td_stripoffset=null;
            td_stripbytecount=null;
            td_stripbytecountsorted=0;	// is the bytecount array sorted ascending?
            td_nsubifd=0;
            td_subifd=null;

            // YCbCr parameters
            td_ycbcrsubsampling=new ushort[2];
            td_ycbcrpositioning=0;

            // Colorimetry parameters
            td_refblackwhite=null;
            td_transferfunction=new ushort[3][];

            // CMYK parameters
            td_inknameslen=0;
            td_inknames=null;

            td_customValueCount=0;
            td_customValues.Clear();
        }