Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.062 Beiträge
 
Delphi 10.4 Sydney
 
#14

AW: Direct2D.Canvas in einer Bitmap speichern

  Alt 31. Mär 2023, 08:37
Ja sicher klappt das bei mir?!
Sonst hätte ich den Quelltext ja nicht gepostet.
Arbeitest du denn an einen richtigen Rechner mit dedizierter GPU (Intel, AMD, Nvidia) oder müssen wir erstmal irgendwelche Probleme wegen Remote Desktop, Terminalsession oder virtueller Maschine mit ungenügender GPU-Unterstützung ausschließen???

CopyBitmap.Map muss ja funktionieren, weil es mit Succeeded(HR) abgesichert.
Was sagt denn der Debugger? Sind alle Werte sinnvoll belegt?

Ergänze bitte mal den Quelltext wie folgt:
Delphi-Quellcode:
                    VCLBitmap := TBitmap.Create(SizeU.Width, SizeU.Height);
                    try
                        VCLBitmap.PixelFormat := TPixelFormat.pf32bit;
                        OutputDebugString(PChar('VCLBitmap.Canvas.Handle: ' + THandle(VCLBitmap.Canvas.Handle).ToHexString));
                        OutputDebugString(PChar('VCLBitmap.Handle: ' + THandle(VCLBitmap.Handle).ToHexString));
                        OutputDebugString(PChar('VCLBitmap.Height: ' + VCLBitmap.Height.ToString));
                        OutputDebugString(PChar('MappedRect.bits: ' + THandle(MappedRect.bits).ToHexString));
                        OutputDebugString(PChar(' BitmapInfo.bmiHeader.biSize: ' + BitmapInfo.bmiHeader.biSize.ToString));
                        OutputDebugString(PChar(' BitmapInfo.bmiHeader.biHeight: ' + BitmapInfo.bmiHeader.biHeight.ToString));
                        OutputDebugString(PChar(' BitmapInfo.bmiHeader.biWidth: ' + BitmapInfo.bmiHeader.biWidth.ToString));
                        OutputDebugString(PChar(' BitmapInfo.bmiHeader.biPlanes: ' + BitmapInfo.bmiHeader.biPlanes.ToString));
                        OutputDebugString(PChar(' BitmapInfo.bmiHeader.biBitCount: ' + BitmapInfo.bmiHeader.biBitCount.ToString));

                        NumberOfScanLinesCopied := SetDIBits(VCLBitmap.Canvas.Handle, VCLBitmap.Handle, 0, VCLBitmap.Height, MappedRect.bits,
                          BitmapInfo, DIB_RGB_COLORS);

                        if NumberOfScanLinesCopied > 0 then
                        begin
                            if ABitmapFileName = 'then
                            begin
                                ABitmapFilename := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + 'Test.bmp';
                            end;
                            VCLBitmap.SaveToFile(ABitmapFilename);
                        end
                        else
                            RaiseLastOSError;
                    finally
                        VCLBitmap.Free;
                    end;

Da müsste dann was rauskommen, was ungefähr so aussieht und Win32:
Code:
Debug Output: VCLBitmap.Canvas.Handle: C101322F Process Direct2DSave.exe (2140)
Debug Output: VCLBitmap.Handle: B905326C Process Direct2DSave.exe (2140)
Debug Output: VCLBitmap.Height: 442 Process Direct2DSave.exe (2140)
Debug Output: MappedRect.bits: 03A30000 Process Direct2DSave.exe (2140)
Debug Output:    BitmapInfo.bmiHeader.biSize: 40 Process Direct2DSave.exe (2140)
Debug Output:    BitmapInfo.bmiHeader.biHeight: -442 Process Direct2DSave.exe (2140)
Debug Output:    BitmapInfo.bmiHeader.biWidth: 640 Process Direct2DSave.exe (2140)
Debug Output:    BitmapInfo.bmiHeader.biPlanes: 1 Process Direct2DSave.exe (2140)
Debug Output:    BitmapInfo.biBitCount.biSize: 32 Process Direct2DSave.exe (2140)

Geändert von TiGü (31. Mär 2023 um 09:49 Uhr)
  Mit Zitat antworten Zitat