public unsafe void tBitmap24ToGraphicsStreamX8R8G8B8(BitmapUtil.BITMAPINFOHEADER *pBITMAPINFOHEADER, DataStream ds, int nWidth, int nHeight) { int nBmpWidth = pBITMAPINFOHEADER->biWidthビットマップの幅dot; int nBmpHeight = pBITMAPINFOHEADER->biHeightビットマップの高さdot; int nBmpLineByte = (nBmpWidth * 3) + ((4 - ((nBmpWidth * 3) % 4)) % 4); uint *pTexture = (uint *)ds.DataPointer.ToPointer(); byte *pBitmap = (byte *)(pBITMAPINFOHEADER + 1); for (int i = 0; i < nBmpHeight; i++) { if (i >= nHeight) { break; } for (int j = 0; j < nBmpWidth; j++) { if (j >= nWidth) { break; } uint B = *((pBitmap + (((nBmpHeight - i) - 1) * nBmpLineByte)) + (j * 3) + 0); uint G = *((pBitmap + (((nBmpHeight - i) - 1) * nBmpLineByte)) + (j * 3) + 1); uint R = *((pBitmap + (((nBmpHeight - i) - 1) * nBmpLineByte)) + (j * 3) + 2); *(pTexture + (i * nWidth) + j) = (R << 16) | (G << 8) | B; } } }
public unsafe void tBitmap24ToGraphicsStreamR5G6B5(BitmapUtil.BITMAPINFOHEADER *pBITMAPINFOHEADER, DataStream gs, int nWidth, int nHeight) { int nBmpWidth = pBITMAPINFOHEADER->biWidthビットマップの幅dot; int nBmpHeight = pBITMAPINFOHEADER->biHeightビットマップの高さdot; int nBmpLineByte = (nBmpWidth * 3) + ((4 - ((nBmpWidth * 3) % 4)) % 4); ushort *pTexture = (ushort *)gs.DataPointer.ToPointer(); byte * pBitmap = (byte *)(pBITMAPINFOHEADER + 1); for (int i = 0; i < nBmpHeight; i++) { if (i >= nHeight) { break; } for (int j = 0; j < nBmpWidth; j++) { if (j >= nWidth) { break; } ushort B = (ushort)((*((pBitmap + (((nBmpHeight - i) - 1) * nBmpLineByte)) + (j * 3) + 0) >> 3) & 0x1f); ushort G = (ushort)((*((pBitmap + (((nBmpHeight - i) - 1) * nBmpLineByte)) + (j * 3) + 1) >> 2) & 0x3f); ushort R = (ushort)((*((pBitmap + (((nBmpHeight - i) - 1) * nBmpLineByte)) + (j * 3) + 2) >> 3) & 0x1f); *(pTexture + (i * nWidth) + j) = (ushort)((R << 11) | (G << 5) | B); } } }
private unsafe void t描画処理_プレビュー画像() { if (!CDTXMania.stage選曲.bスクロール中 && (((this.ct遅延表示 != null) && (this.ct遅延表示.n現在の値 > 0)) && !this.b新しいプレビューファイルをまだ読み込んでいない)) { int x = this.n本体X + 0x12; int y = this.n本体Y + 0x10; float num3 = ((float)this.ct遅延表示.n現在の値) / 100f; float num4 = 0.9f + (0.1f * num3); if ((this.nAVI再生開始時刻 != -1) && (this.sfAVI画像 != null)) { if (this.b動画フレームを作成した && (this.pAVIBmp != IntPtr.Zero)) { DataRectangle rectangle = this.sfAVI画像.LockRectangle(LockFlags.None); DataStream data = rectangle.Data; int num5 = rectangle.Pitch / this.sfAVI画像.Description.Width; BitmapUtil.BITMAPINFOHEADER *pBITMAPINFOHEADER = (BitmapUtil.BITMAPINFOHEADER *) this.pAVIBmp.ToPointer(); if (pBITMAPINFOHEADER->biBitCount == 0x18) { switch (num5) { case 2: this.avi.tBitmap24ToGraphicsStreamR5G6B5(pBITMAPINFOHEADER, data, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height); break; case 4: this.avi.tBitmap24ToGraphicsStreamX8R8G8B8(pBITMAPINFOHEADER, data, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height); break; } } this.sfAVI画像.UnlockRectangle(); this.b動画フレームを作成した = false; } using (Surface surface = CDTXMania.app.Device.GetBackBuffer(0, 0)) { try { CDTXMania.app.Device.UpdateSurface(this.sfAVI画像, new Rectangle(0, 0, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height), surface, new Point(x, y)); } catch // #32335 2013.10.26 yyagi: codecがないと、D3DERR_INVALIDCALLが発生する場合がある { } return; } } if (this.r表示するプレビュー画像 != null) { int width = this.r表示するプレビュー画像.sz画像サイズ.Width; int height = this.r表示するプレビュー画像.sz画像サイズ.Height; if (width > 400) { width = 400; } if (height > 400) { height = 400; } x += (400 - ((int)(width * num4))) / 2; y += (400 - ((int)(height * num4))) / 2; this.r表示するプレビュー画像.n透明度 = (int)(255f * num3); this.r表示するプレビュー画像.vc拡大縮小倍率.X = num4; this.r表示するプレビュー画像.vc拡大縮小倍率.Y = num4; this.r表示するプレビュー画像.t2D描画(CDTXMania.app.Device, x + 22, y + 12, new Rectangle(0, 0, width, height)); } } }
public unsafe int t進行描画(int x, int y) { if (!base.b活性化してない) { Rectangle rectangle; Rectangle rectangle2; if (!this.bDShowクリップを再生している || (this.dsBGV.dshow == null || this.dsBGV == null)) { if (((this.n移動開始時刻ms == -1) || (this.rAVI == null)) || (this.rAVI.avi == null)) { return(0); } } if (this.tx描画用 == null) { return(0); } int time = (int)((CSound管理.rc演奏用タイマ.n現在時刻 - this.n移動開始時刻ms) * (((double)TJAPlayer3.ConfigIni.n演奏速度) / 20.0)); int frameNoFromTime = 0; #region [ frameNoFromTime ] if ((this.dsBGV != null)) { if (this.fAVIアスペクト比 > 1.77f) { this.dsBGV.dshow.MediaSeeking.GetPositions(out this.lDshowPosition, out this.lStopPosition); frameNoFromTime = (int)lDshowPosition; } else { frameNoFromTime = this.rAVI.avi.GetFrameNoFromTime(time); } } #endregion if ((this.n総移動時間ms != 0) && (this.n総移動時間ms < time)) { this.n総移動時間ms = 0; this.n移動開始時刻ms = -1; return(0); } //2014.11.17 kairera0467 AVIが無い状態でAVIのフレームカウントをさせるとエラーを吐くため、かなり雑ではあるが対策。 if ((this.n総移動時間ms == 0) && this.rAVI.avi != null ? (frameNoFromTime >= this.rAVI.avi.GetMaxFrameCount()) : false) { this.n移動開始時刻ms = -1L; } if ((((this.n前回表示したフレーム番号 != frameNoFromTime) || !this.bフレームを作成した)) && (fAVIアスペクト比 < 1.77f)) { this.pBmp = this.rAVI.avi.GetFramePtr(frameNoFromTime); this.n前回表示したフレーム番号 = frameNoFromTime; this.bフレームを作成した = true; } //ループ防止 if (this.lDshowPosition >= this.lStopPosition && this.dsBGV != null) { this.dsBGV.dshow.MediaSeeking.SetPositions( DsLong.FromInt64((long)(0)), AMSeekingSeekingFlags.AbsolutePositioning, null, AMSeekingSeekingFlags.NoPositioning); this.dsBGV.dshow.MediaCtrl.Stop(); this.bDShowクリップを再生している = false; } #region [ フレーム幅 ] //uintじゃなくてint。DTXHDでは無駄に変換してたね。 int nフレーム幅 = 0; int nフレーム高さ = 0; if (this.dsBGV != null) { nフレーム幅 = this.dsBGV.dshow.n幅px; nフレーム高さ = this.dsBGV.dshow.n高さpx; } else if (this.rAVI != null || this.rAVI.avi != null) { nフレーム幅 = (int)this.rAVI.avi.nフレーム幅; nフレーム高さ = (int)this.rAVI.avi.nフレーム高さ; } #endregion //2014.11.17 kairera0467 フレーム幅をrAVIから参照していたため、先にローカル関数で決めるよう変更。 Size szフレーム幅 = new Size(nフレーム幅, nフレーム高さ); Size sz最大フレーム幅 = new Size(1280, 720); Size size3 = new Size(this.n開始サイズW, this.n開始サイズH); Size size4 = new Size(this.n終了サイズW, this.n終了サイズH); Point location = new Point(this.n画像側開始位置X, this.n画像側終了位置Y); Point point2 = new Point(this.n画像側終了位置X, this.n画像側終了位置Y); Point point3 = new Point(this.n表示側開始位置X, this.n表示側開始位置Y); Point point4 = new Point(this.n表示側終了位置X, this.n表示側終了位置Y); long num3 = this.n総移動時間ms; long num4 = this.n移動開始時刻ms; if (CSound管理.rc演奏用タイマ.n現在時刻 < num4) { num4 = CSound管理.rc演奏用タイマ.n現在時刻; } time = (int)((CSound管理.rc演奏用タイマ.n現在時刻 - num4) * (((double)TJAPlayer3.ConfigIni.n演奏速度) / 20.0)); if (num3 == 0) { rectangle = new Rectangle(location, size3); rectangle2 = new Rectangle(point3, size3); } else { double num5 = ((double)time) / ((double)num3); Size size5 = new Size(size3.Width + ((int)((size4.Width - size3.Width) * num5)), size3.Height + ((int)((size4.Height - size3.Height) * num5))); rectangle = new Rectangle((int)((point2.X - location.X) * num5), (int)((point2.Y - location.Y) * num5), ((int)((point2.X - location.X) * num5)) + size5.Width, ((int)((point2.Y - location.Y) * num5)) + size5.Height); rectangle2 = new Rectangle((int)((point4.X - point3.X) * num5), (int)((point4.Y - point3.Y) * num5), ((int)((point4.X - point3.X) * num5)) + size5.Width, ((int)((point4.Y - point3.Y) * num5)) + size5.Height); if (((rectangle.Right <= 0) || (rectangle.Bottom <= 0)) || ((rectangle.Left >= szフレーム幅.Width) || (rectangle.Top >= szフレーム幅.Height))) { return(0); } if (((rectangle2.Right <= 0) || (rectangle2.Bottom <= 0)) || ((rectangle2.Left >= sz最大フレーム幅.Width) || (rectangle2.Top >= sz最大フレーム幅.Height))) { return(0); } if (rectangle.X < 0) { int num6 = -rectangle.X; rectangle2.X += num6; rectangle2.Width -= num6; rectangle.X = 0; rectangle.Width -= num6; } if (rectangle.Y < 0) { int num7 = -rectangle.Y; rectangle2.Y += num7; rectangle2.Height -= num7; rectangle.Y = 0; rectangle.Height -= num7; } if (rectangle.Right > szフレーム幅.Width) { int num8 = rectangle.Right - szフレーム幅.Width; rectangle2.Width -= num8; rectangle.Width -= num8; } if (rectangle.Bottom > szフレーム幅.Height) { int num9 = rectangle.Bottom - szフレーム幅.Height; rectangle2.Height -= num9; rectangle.Height -= num9; } if (rectangle2.X < 0) { int num10 = -rectangle2.X; rectangle.X += num10; rectangle.Width -= num10; rectangle2.X = 0; rectangle2.Width -= num10; } if (rectangle2.Y < 0) { int num11 = -rectangle2.Y; rectangle.Y += num11; rectangle.Height -= num11; rectangle2.Y = 0; rectangle2.Height -= num11; } if (rectangle2.Right > sz最大フレーム幅.Width) { int num12 = rectangle2.Right - sz最大フレーム幅.Width; rectangle.Width -= num12; rectangle2.Width -= num12; } if (rectangle2.Bottom > sz最大フレーム幅.Height) { int num13 = rectangle2.Bottom - sz最大フレーム幅.Height; rectangle.Height -= num13; rectangle2.Height -= num13; } if ((rectangle.X >= rectangle.Right) || (rectangle.Y >= rectangle.Bottom)) { return(0); } if ((rectangle2.X >= rectangle2.Right) || (rectangle2.Y >= rectangle2.Bottom)) { return(0); } if (((rectangle.Right < 0) || (rectangle.Bottom < 0)) || ((rectangle.X > szフレーム幅.Width) || (rectangle.Y > szフレーム幅.Height))) { return(0); } if (((rectangle2.Right < 0) || (rectangle2.Bottom < 0)) || ((rectangle2.X > sz最大フレーム幅.Width) || (rectangle2.Y > sz最大フレーム幅.Height))) { return(0); } } if ((this.tx描画用 != null)) { if ((this.bDShowクリップを再生している == true) && this.dsBGV.dshow != null) { #region [ ワイドクリップ ] this.dsBGV.dshow.t現時点における最新のスナップイメージをTextureに転写する(this.tx描画用); this.dsBGV.dshow.t現時点における最新のスナップイメージをTextureに転写する(this.tx窓描画用); if (TJAPlayer3.ConfigIni.eClipDispType == EClipDispType.背景のみ || TJAPlayer3.ConfigIni.eClipDispType == EClipDispType.両方) { if (this.dsBGV.dshow.b上下反転) { this.tx描画用.t2D上下反転描画(TJAPlayer3.app.Device, x, y); } else { this.tx描画用.t2D描画(TJAPlayer3.app.Device, x, y); } } #endregion } } else if ((this.tx描画用 != null) && (this.n総移動時間ms != -1)) { if (this.bフレームを作成した && (this.pBmp != IntPtr.Zero)) { DataRectangle rectangle3 = this.tx描画用.texture.LockRectangle(0, LockFlags.None); DataStream data = rectangle3.Data; int num14 = rectangle3.Pitch / this.tx描画用.szテクスチャサイズ.Width; BitmapUtil.BITMAPINFOHEADER *pBITMAPINFOHEADER = (BitmapUtil.BITMAPINFOHEADER *) this.pBmp.ToPointer(); if (pBITMAPINFOHEADER->biBitCount == 0x18) { switch (num14) { case 2: this.rAVI.avi.tBitmap24ToGraphicsStreamR5G6B5(pBITMAPINFOHEADER, data, this.tx描画用.szテクスチャサイズ.Width, this.tx描画用.szテクスチャサイズ.Height); break; case 4: this.rAVI.avi.tBitmap24ToGraphicsStreamX8R8G8B8(pBITMAPINFOHEADER, data, this.tx描画用.szテクスチャサイズ.Width, this.tx描画用.szテクスチャサイズ.Height); break; } } this.tx描画用.texture.UnlockRectangle(0); this.bフレームを作成した = false; } double dbAVI比率 = this.rAVI.avi.nフレーム幅 / this.rAVI.avi.nフレーム高さ; //とりあえず16:9以外は再生しない。 if (dbAVI比率 < 1.77) { this.tx描画用.t2D描画(TJAPlayer3.app.Device, 0, 0); } } #region [キー入力処理] //IInputDevice keyboard = CDTXMania.Input管理.Keyboard; //if ( keyboard.bキーが押された( (int) SlimDX.DirectInput.Key.F1 ) && // ( keyboard.bキーが押されている( (int) SlimDX.DirectInput.Key.RightShift ) || keyboard.bキーが押されている( (int) SlimDX.DirectInput.Key.LeftShift ) ) ) //{ // if( this.b再生トグル == true ) // { // if( this.dsBGV != null ) // { // if( this.dsBGV.dshow != null ) // this.dsBGV.dshow.MediaCtrl.Pause(); // } // this.b再生トグル = true; // } // else if( this.b再生トグル == false ) // { // if(this.dsBGV != null ) // { // if( this.dsBGV.dshow != null ) // this.dsBGV.dshow.MediaCtrl.Run(); // } // this.b再生トグル = false; // } //} #endregion } return(0); }
private unsafe void t描画処理_プレビュー画像() { if (!CDTXMania.stageSongSelection.bScrolling && (((this.ct遅延表示 != null) && (this.ct遅延表示.nCurrentValue > 0)) && !this.b新しいプレビューファイルをまだ読み込んでいない)) { int n差X = 0x25; int n差Y = 0x18; int n表示ジャケットサイズ = 368; if (this.actステータスパネル.txパネル本体 != null) { n差X = 8; n差Y = 8; n表示ジャケットサイズ = 292; } int x = this.n本体X + n差X; int y = this.n本体Y + n差Y; int z = n表示ジャケットサイズ; float num3 = ((float)this.ct遅延表示.nCurrentValue) / 100f; float num4 = 0.9f + (0.1f * num3); if ((this.nAVI再生開始時刻 != -1) && (this.sfAVI画像 != null)) { if (this.b動画フレームを作成した && (this.pAVIBmp != IntPtr.Zero)) { DataRectangle rectangle = this.sfAVI画像.LockRectangle(LockFlags.None); IntPtr dataPointer = rectangle.DataPointer; int num5 = rectangle.Pitch / this.sfAVI画像.Description.Width; BitmapUtil.BITMAPINFOHEADER *pBITMAPINFOHEADER = (BitmapUtil.BITMAPINFOHEADER *) this.pAVIBmp.ToPointer(); if (pBITMAPINFOHEADER->biBitCount == 0x18) { switch (num5) { case 2: this.avi.tBitmap24ToGraphicsStreamR5G6B5(pBITMAPINFOHEADER, dataPointer, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height); break; case 4: this.avi.tBitmap24ToGraphicsStreamX8R8G8B8(pBITMAPINFOHEADER, dataPointer, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height); break; } } this.sfAVI画像.UnlockRectangle(); this.b動画フレームを作成した = false; } x += (z - this.sfAVI画像.Description.Width) / 2; y += (z - this.sfAVI画像.Description.Height) / 2; using (Surface surface = CDTXMania.app.Device.GetBackBuffer(0, 0)) { CDTXMania.app.Device.UpdateSurface(this.sfAVI画像, new SharpDX.Rectangle(0, 0, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height), surface, new SharpDX.Point(x, y)); return; } } if (this.r表示するプレビュー画像 != null) { float width = this.r表示するプレビュー画像.szImageSize.Width; float height = this.r表示するプレビュー画像.szImageSize.Height; float f倍率; if (((float)z / width) > ((float)z / height)) { f倍率 = (float)z / height; } else { f倍率 = (float)z / width; } x += (z - ((int)(width * num4 * f倍率))) / 2; y += (z - ((int)(height * num4 * f倍率))) / 2; this.r表示するプレビュー画像.nTransparency = (int)(255f * num3); this.r表示するプレビュー画像.vcScaleRatio.X = num4 * f倍率; this.r表示するプレビュー画像.vcScaleRatio.Y = num4 * f倍率; this.r表示するプレビュー画像.tDraw2D(CDTXMania.app.Device, x, y); } } }
private unsafe void t描画処理_プレビュー画像() { if (!TJAPlayer3.stage選曲.bスクロール中 && (((this.ct遅延表示 != null) && (this.ct遅延表示.n現在の値 > 0)) && !this.b新しいプレビューファイルをまだ読み込んでいない)) { int x = this.n本体X + 0x12; int y = this.n本体Y + 0x10; float num3 = ((float)this.ct遅延表示.n現在の値) / 100f; float num4 = 0.9f + (0.1f * num3); if ((this.nAVI再生開始時刻 != -1) && (this.sfAVI画像 != null)) { if (this.b動画フレームを作成した && (this.pAVIBmp != IntPtr.Zero)) { DataRectangle rectangle = this.sfAVI画像.LockRectangle(LockFlags.None); DataStream data = new DataStream(rectangle.DataPointer, this.sfAVI画像.Description.Width * rectangle.Pitch, true, false); int num5 = rectangle.Pitch / this.sfAVI画像.Description.Width; BitmapUtil.BITMAPINFOHEADER *pBITMAPINFOHEADER = (BitmapUtil.BITMAPINFOHEADER *) this.pAVIBmp.ToPointer(); if (pBITMAPINFOHEADER->biBitCount == 0x18) { switch (num5) { case 2: this.avi.tBitmap24ToGraphicsStreamR5G6B5(pBITMAPINFOHEADER, data, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height); break; case 4: this.avi.tBitmap24ToGraphicsStreamX8R8G8B8(pBITMAPINFOHEADER, data, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height); break; } } this.sfAVI画像.UnlockRectangle(); this.b動画フレームを作成した = false; } using (Surface surface = TJAPlayer3.app.Device.GetBackBuffer(0, 0)) { try { TJAPlayer3.app.Device.UpdateSurface(this.sfAVI画像, new SharpDX.Mathematics.Interop.RawRectangle(0, 0, this.sfAVI画像.Description.Width, this.sfAVI画像.Description.Height), surface, new SharpDX.Mathematics.Interop.RawPoint(x, y)); } catch (Exception e) // #32335 2013.10.26 yyagi: codecがないと、D3DERR_INVALIDCALLが発生する場合がある { Trace.TraceError("codecがないと、D3DERR_INVALIDCALLが発生する場合がある"); Trace.TraceError(e.ToString()); Trace.TraceError("例外が発生しましたが処理を継続します。 (ba21ae56-afaa-47b9-a5c7-1a6bb21085eb)"); } return; } } if (this.r表示するプレビュー画像 != null) { int width = this.r表示するプレビュー画像.sz画像サイズ.Width; int height = this.r表示するプレビュー画像.sz画像サイズ.Height; if (width > 400) { width = 400; } if (height > 400) { height = 400; } x += (400 - ((int)(width * num4))) / 2; y += (400 - ((int)(height * num4))) / 2; this.r表示するプレビュー画像.Opacity = (int)(255f * num3); this.r表示するプレビュー画像.vc拡大縮小倍率.X = num4; this.r表示するプレビュー画像.vc拡大縮小倍率.Y = num4; this.r表示するプレビュー画像.t2D描画(TJAPlayer3.app.Device, x + 22, y + 12, new Rectangle(0, 0, width, height)); } } }