Esempio n. 1
0
        public static int FileData2SoftImage(byte[] fileData)
        {
            int siHandle = -1;

            DDSystem.PinOn(fileData, p => siHandle = DX.LoadSoftImageToMem(p, fileData.Length));

            if (siHandle == -1)
            {
                throw new DDError();
            }

            int w;
            int h;

            GetSoftImageSize(siHandle, out w, out h);

            // RGB -> RGBA
            {
                int h2 = DX.MakeARGB8ColorSoftImage(w, h);

                if (h2 == -1)                 // ? 失敗
                {
                    throw new DDError();
                }

                if (DX.BltSoftImage(0, 0, w, h, siHandle, 0, 0, h2) != 0)                 // ? 失敗
                {
                    throw new DDError();
                }

                if (DX.DeleteSoftImage(siHandle) != 0)                 // ? 失敗
                {
                    throw new DDError();
                }

                siHandle = h2;
            }

            return(siHandle);
        }
Esempio n. 2
0
        public int GetHandle(int handleIndex)
        {
            if (this.Handles == null)
            {
                this.Handles = new int[this.HandleCount];

                {
                    byte[] fileData = this.Func_GetFileData();
                    int    handle   = -1;

                    DDSystem.PinOn(fileData, p => handle = DX.LoadSoundMemByMemImage(p, fileData.Length));

                    if (handle == -1)                     // ? 失敗
                    {
                        throw new DDError();
                    }

                    this.Handles[0] = handle;
                }

                for (int index = 1; index < this.HandleCount; index++)
                {
                    int handle = DX.DuplicateSoundMem(this.Handles[0]);

                    if (handle == -1)                     // ? 失敗
                    {
                        throw new DDError();
                    }

                    this.Handles[index] = handle;
                }

                this.PostLoaded();
            }
            return(this.Handles[handleIndex]);
        }