pipistrello
Mitglied
edit: sorry gehört hier nicht hin sondern in .NET Grafik & Sound
Ist es möglich ein Bild in einer Konsolenanwendung anzeigen zu lassen?
Hab zwar hier m Forum was gefunden, aber leider nur unter c/c++:
Dachte eventuell an sowas hier:
Ist es möglich ein Bild in einer Konsolenanwendung anzeigen zu lassen?
Hab zwar hier m Forum was gefunden, aber leider nur unter c/c++:
Code:
#include <windows.h>
#include <stdio.h>
//#pragma comment(lib,"gdi32.lib")
int LoadBmp2Console(char *szBitmap, int PosX, int PosY)
{
HBITMAP hBitmap = (HBITMAP)LoadImage(NULL,szBitmap,
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
if (!hBitmap) return 1;
BITMAP bmp;
GetObject(hBitmap,sizeof(bmp),&bmp);
HWND hwnd = FindWindow("ConsoleWindowClass",NULL);
if (!hwnd) return 2;
HDC hDC = GetDC(hwnd);
if (!hDC) return 3;
HDC hBitmapDC = CreateCompatibleDC(hDC);
if (!hBitmapDC) return 4;
SelectObject(hBitmapDC,hBitmap);
BitBlt(hDC,PosX,PosY,bmp.bmHeight,bmp.bmWidth,hBitmapDC,0,0,SRCCOPY);
DeleteObject(hBitmap);
ReleaseDC(hwnd,hBitmapDC);
ReleaseDC(hwnd,hDC);
return 0;
}
int main()
{
int Status = LoadBmp2Console("bitmap.bmp",10,10);
if(Status!=0)printf("Fehler: %i",Status);
getchar();
return 0;
}
Dachte eventuell an sowas hier:
Code:
String source = @"c:\max.bmp";
Bitmap bild = new Bitmap(source);
Int32 x, y, width, height;
x = Console.WindowLeft;
y = Console.WindowTop;
width = Console.WindowWidth;
height = Console.WindowHeight;
using (Graphics objekt = Graphics.FromImage(bild))
{
objekt.DrawImage(bild, new Rectangle(x, y, width, height));
}
Console.ReadKey();
Console.Clear();
Zuletzt bearbeitet: