J'essaie de créer un graphique DirectShow pour lire une vidéo composée de bitmaps 8 bits en niveaux de gris. (en utilisant directshow.net.)directshow Renderstream échoue avec des bitmaps en niveaux de gris
J'utilise un filtre source et le moteur de rendu vmr9.
La broche de sortie de filtre source est définie en utilisant le code suivant:
bmi.Size = Marshal.SizeOf(typeof(BitmapInfoHeader));
bmi.Width = width;
bmi.Height = height;;
bmi.Planes = 1;
bmi.BitCount = (short)bitcount;
bmi.Compression = 0;
bmi.ImageSize = Math.Abs(bmi.Height) * bmi.Width * bmi.BitCount/8;
bmi.ClrUsed = bmi.BitCount <= 8 ? 256 : 0;
bmi.ClrImportant = 0;
//bmi.XPelsPerMeter = 0;
//bmi.YPelsPerMeter = 0;
bool isGrayScale = bmi.BitCount <= 8 ? true : false;
int formatSize = Marshal.SizeOf(typeof(BitmapInfoHeader));
if (isGrayScale == true)
{
MessageWriter.Log.WriteTrace("Playback is grayscale.");
/// Color table holds an array of 256 RGBQAD values
/// Those are relevant only for grayscale bitmaps
formatSize += Marshal.SizeOf(typeof(RGBQUAD)) * bmi.ClrUsed;
}
IntPtr ptr = Marshal.AllocHGlobal(formatSize);
Marshal.StructureToPtr(bmi, ptr, false);
if (isGrayScale == true)
{
/// Adjust the pointer to the beginning of the
/// ColorTable address and create the grayscale color table
IntPtr ptrNext = (IntPtr)((int)ptr + Marshal.SizeOf(typeof(BitmapInfoHeader)));
for (int i = 0; i < bmi.ClrUsed; i++)
{
RGBQUAD rgbCell = new RGBQUAD();
rgbCell.rgbBlue = rgbCell.rgbGreen = rgbCell.rgbRed = (byte)i;
rgbCell.rgbReserved = 0;
Marshal.StructureToPtr(rgbCell, ptrNext, false);
ptrNext = (IntPtr)((int)ptrNext + Marshal.SizeOf(typeof(RGBQUAD)));
}
}
Cela provoque Renderstream revenir « Aucune combinaison de filtres intermédiaires n'a pu être trouvée pour établir la connexion. »
Aidez s'il vous plaît!
Merci.
Je ne comprends pas ... Je crée le BITMAPINFOHEADER afin de fournir la broche de sortie du filtre source. Où puis-je le définir sur YUV ou sur l'un des autres types que vous avez mentionnés? – Roey