Image = DX.CreateGraphFromMem(p, buff.Length);
の部分でメモリの使用量が増えてしまします。
何が原因なのでしょうか?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.MemoryMappedFiles;
using System.IO;
using DxLibDLL;
namespace app
{
public partial class Form1 : Form
{
public Form1()
{
int Image;
InitializeComponent();
//dxライブラリ描画先
DX.SetUserWindow(this.Handle);
//dxライブラリ初期化
DX.DxLib_Init();
// 描画先を裏画面にする
DX.SetDrawScreen(DX.DX_SCREEN_BACK);
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
DX.DxLib_End();
}
public void MainLoop()
{
DX.ClsDrawScreen();// 画面に描かれているものを一回全部消す
this.Draw();
DX.ScreenFlip(); // 裏画面の内容を表画面に反映させる
}
public void FrameReady(...)
{
Bitmap bitmap = e.Bitmap;
// Bitmapからグラフィックを作成
using (MemoryStream ms = new MemoryStream())
{
bitmap.Save(ms, ImageFormat.Bmp);
byte[] buff = ms.ToArray();
unsafe
{
fixed (byte* p = buff)
{
DX.SetDrawValidGraphCreateFlag(DX.TRUE);
DX.SetDrawValidAlphaChannelGraphCreateFlag(DX.TRUE);
Image = DX.CreateGraphFromMem(p, buff.Length);
DX.SetDrawValidGraphCreateFlag(DX.FALSE);
DX.SetDrawValidAlphaChannelGraphCreateFlag(DX.FALSE);
}
}
}
}
void Draw(){
DX.DrawGraph(0, 0, Image, 0);
}
}
}