프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ConverterService / ImageFields / ImageFields.cs @ 3fb3351b

이력 | 보기 | 이력해설 | 다운로드 (4.66 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Security.Permissions;
6

    
7
namespace ImageFields
8
{
9
    public class ImageFields : ImageFieldsBase
10
    {
11
         // Fields
12
    private bool copyMetadata;
13

    
14
    // Methods
15
    public ImageFields()
16
    {
17
        base.UseOptimizations = true;
18
    }
19

    
20
    [FileIOPermission(SecurityAction.LinkDemand)]
21
    public void Create(string source, string destination)
22
    {
23
        EventHandler<StreamEventArgs> handler = null;
24
        EventHandler<StreamEventArgs> handler2 = null;
25
        EventHandler<StreamEventArgs> handler3 = null;
26
        EventHandler<StreamEventArgs> handler4 = null;
27
        EventHandler<ImageInfoEventArgs> handler5 = null;
28
        EventHandler<OutputInfoEventArgs> handler6 = null;
29
        EventHandler<DirectoryEventArgs> handler7 = null;
30
        List<Image> images = new List<Image>();
31
        Image item = new Image(source);
32
        images.Add(item);
33
        SparseImageCreator creator = new SparseImageCreator();
34
        SmoothStreamingFile file = null;
35
        if (base.ServerFormat == ServerFormats.SmoothStreaming)
36
        {
37
            file = new SmoothStreamingFile(destination);
38
            creator.CreateDirectory += new EventHandler<DirectoryEventArgs>(file.CreateDirectory);
39
            creator.OutputCompleted += new EventHandler<StreamEventArgs>(file.OutputCompleted);
40
            creator.OutputNeeded += new EventHandler<StreamEventArgs>(file.OutputNeeded);
41
        }
42
        else
43
        {
44
            if (base.HasInputNeededHandler())
45
            {
46
                if (handler == null)
47
                {
48
                    handler = (o, e) => base.OnInputNeeded(e);
49
                }
50
                creator.InputNeeded += handler;
51
            }
52
            if (base.HasInputCompletedHandler())
53
            {
54
                if (handler2 == null)
55
                {
56
                    handler2 = (o, e) => base.OnInputCompleted(e);
57
                }
58
                creator.InputCompleted += handler2;
59
            }
60
            if (base.HasOutputNeededHandler())
61
            {
62
                if (handler3 == null)
63
                {
64
                    handler3 = (o, e) => base.OnOutputNeeded(e);
65
                }
66
                creator.OutputNeeded += handler3;
67
            }
68
            if (base.HasOutputCompletedHandler())
69
            {
70
                if (handler4 == null)
71
                {
72
                    handler4 = (o, e) => base.OnOutputCompleted(e);
73
                }
74
                creator.OutputCompleted += handler4;
75
            }
76
            if (base.HasInputImageInfoHandler())
77
            {
78
                if (handler5 == null)
79
                {
80
                    handler5 = (o, e) => base.OnInputImageInfo(e);
81
                }
82
                creator.InputImageInfo += handler5;
83
            }
84
            if (base.HasOutputInfoHandler())
85
            {
86
                if (handler6 == null)
87
                {
88
                    handler6 = (o, e) => base.OnOutputInfo(e);
89
                }
90
                creator.OutputInfo += handler6;
91
            }
92
            if (handler7 == null)
93
            {
94
                handler7 = (o, e) => base.OnCreateDirectory(e);
95
            }
96
            creator.CreateDirectory += handler7;
97
        }
98
        creator.ImageQuality = base.ImageQuality;
99
        creator.TileSize = this.TileSize;
100
        creator.TileOverlap = base.TileOverlap;
101
        creator.TileFormat = base.TileFormat;
102
        creator.CopyMetadata = this.CopyMetadata;
103
        creator.UseOptimizations = base.UseOptimizations;
104
        creator.MaxLevel = base.MaxLevel;
105
        creator.LowLevelPass = base.LowLevelPass;
106
        creator.ServerFormatXML = base.ServerFormat;
107
        creator.Create(images, destination);
108
        if (file != null)
109
        {
110
            creator.CreateDirectory -= new EventHandler<DirectoryEventArgs>(file.CreateDirectory);
111
            creator.OutputCompleted -= new EventHandler<StreamEventArgs>(file.OutputCompleted);
112
            creator.OutputNeeded -= new EventHandler<StreamEventArgs>(file.OutputNeeded);
113
            file.Close();
114
        }
115
        GC.Collect(2);
116
        GC.Collect(2);
117
    }
118

    
119
    // Properties
120
    public bool CopyMetadata
121
    {
122
        get
123
        {
124
            return this.copyMetadata;
125
        }
126
        set
127
        {
128
            this.copyMetadata = value;
129
        }
130
    }
131

    
132
    public override int TileSize
133
    {
134
        get
135
        {
136
            return base.TileSize;
137
        }
138
        set
139
        {
140
            if (value < (base.TileOverlap * 2))
141
            {
142
                throw new ArgumentOutOfRangeException("value", "TileSize must be more than twice the TileOverlap.");
143
            }
144
            base.TileSize = value;
145
        }
146
    }
147

    
148
    }
149
}
클립보드 이미지 추가 (최대 크기: 500 MB)