첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
0.00MB

▶ CustomColor.cs

using System;

namespace TestProject
{
    /// <summary>
    /// 커스텀 색상
    /// </summary>
    public struct CustomColor
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region Field

        /// <summary>
        /// 적색
        /// </summary>
        public short Red;

        /// <summary>
        /// 녹색
        /// </summary>
        public short Green;

        /// <summary>
        /// 청색
        /// </summary>
        public short Blue;

        /// <summary>
        /// 알파
        /// </summary>
        public short Alpha;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 밝게하기 - Brighten(value)

        /// <summary>
        /// 밝게하기
        /// </summary>
        /// <param name="value">값</param>
        public void Brighten(short value)
        {
            Red   = (short)Math.Min(short.MaxValue, (int)Red   + value);
            Green = (short)Math.Min(short.MaxValue, (int)Green + value);
            Blue  = (short)Math.Min(short.MaxValue, (int)Blue  + value);
            Alpha = (short)Math.Min(short.MaxValue, (int)Alpha + value);
        }

        #endregion
    }
}

 

728x90

 

▶ Program.cs

using System.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;

namespace TestProject
{
    /// <summary>
    /// 프로그램
    /// </summary>
    class Program
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region 프로그램 시작하기 - Main()

        /// <summary>
        /// 프로그램 시작하기
        /// </summary>
        private static void Main()
        {
            string mapFilePath   = "d:\\ExtremelyLargeImage.data";
            string mapName       = "testMap";
            long   dataOffset    = 0x10000000; // 256MB
            long   dataLength    = 0x20000000; // 512MB
            long   mapFileLength = 0x40000000; // 1GB

            if(!File.Exists(mapFilePath))
            {
                using(MemoryMappedFile file = MemoryMappedFile.CreateFromFile(mapFilePath, FileMode.CreateNew, mapName, mapFileLength))
                {
                }
            }

            using(MemoryMappedFile file = MemoryMappedFile.CreateFromFile(mapFilePath, FileMode.Open, mapName))
            {
                using(MemoryMappedViewAccessor accessor = file.CreateViewAccessor(dataOffset, dataLength))
                {
                    int colorSize = Marshal.SizeOf(typeof(CustomColor));

                    for (long i = 0; i < dataLength; i += colorSize)
                    {
                        accessor.Read(i, out CustomColor color);

                        color.Brighten(10);

                        accessor.Write(i, ref color);
                    }
                }
            }
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요