I'd like to implement this code in my VS C # project, I did a brief search here, but no impelmentation was found. Here is Windows Magnification API .NET is what I want to do, but in this does not have an implementation of MagSetImageScalingCallback.
function MagImageScaling(_HWND: hwnd; _srcdata: Pointer;
_srcheader: MAGIMAGEHEADER; _destdata: Pointer; _destheader: MAGIMAGEHEADER;
_unclipped: TRect; _clipped: TRect; _dirty: HRGN): BOOL; stdcall;
var
_DC: HDC;
_bmp: TBitmap;
_Bild: TBitmap;
_bitmap: HBitmap;
_info: TBitmapInfo;
begin
_DC:= getDC(_HWND);
Fillchar(_info, sizeof(_info), 0);
_info.bmiHeader.biSize:= sizeOf(TBitmapInfoHeader);
_info.bmiHeader.biWidth:= _srcheader.width;
_info.bmiHeader.biHeight:= -_srcheader.height;
_info.bmiHeader.biplanes:= 1;
_info.bmiHeader.biBitCount:= 32;
_info.bmiHeader.biCompression:= BI_RGB;
_bitmap:= 0;
_bitmap:= CreateDIBitmap(_DC, _info.bmiHeader, CBM_INIT, _srcdata, _info, DIB_RGB_COLORS);
_bmp:= TBitmap.Create;
_bmp.PixelFormat:= pf8bit;
_bmp.Width:= _srcheader.width;
_bmp.Height:= -_srcheader.height;
_Bild:= TBitmap.Create;
_Bild.PixelFormat:= pf8bit;
_Bild.Width:= _bmp.Width;
_Bild.Height:= _bmp.Height;
try
_bmp.handle:= _bitmap;
_bmp.Canvas.Lock;
BitBlt(_bmp.Canvas.Handle, 0, 0, _bmp.Width,
_bmp.Height, _bitmap, 0, 0, SRCCOPY);
_bmp.Canvas.Unlock;
_Bild.Canvas.Draw(0, 0, _bmp);
FBitmap2.Width:= _Bild.Width;
FBitmap2.Height:= _Bild.Height;
FBitmap2.Assign(_Bild);
finally
ReleaseDC(_HWND, _DC);
end;
DeleteObject(_bitmap);
DeleteDC(_DC);
FreeAndNil(_bmp);
FreeAndNil(_Bild);
Result:= True;
CallbackDone:= True;
end;
This code in Delphi represents exactly what I want to do in C #. Or just converting this Delphi code to C # would help a lot.