Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Resolution in OSR Browser

Post Reply
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Resolution in OSR Browser

Post by andreykrasnodar »

How to set high resolution (for example, 2560x2048 px) and display it on small (for example, 320x240) paintbox32?
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Resolution in OSR Browser

Post by salvadordf »

You would need to use a hidden Tbitmap in the Tchromium.onpaint event instead of using the paintbox32 directly.
Then draw the tbitmap into the paintbox32.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Resolution in OSR Browser

Post by andreykrasnodar »

I do not understand. Do you have an example code?
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Resolution in OSR Browser

Post by salvadordf »

I'm sorry but I don't have an example.

In fact, we repleaced the paintbox32 component long ago due to some resizing issues and now CEF4Delphi and OldCEF4Delphi use a custom made component.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Resolution in OSR Browser

Post by andreykrasnodar »

I still do not understand.
I need 2 things:
1. Resizing with scaling down (for example twice low).
2. Drawing cursor on browser.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Resolution in OSR Browser

Post by andreykrasnodar »

salvadordf wrote: Wed Aug 05, 2020 8:49 pm You would need to use a hidden Tbitmap in the Tchromium.onpaint event instead of using the paintbox32 directly.
Then draw the tbitmap into the paintbox32.
How can I send buffer of TChromium into TBitmap?
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Resolution in OSR Browser

Post by salvadordf »

In OSR browser you have the bitmap with the browser contents in the TBufferPanel.Buffer property.

Don't forget to call TBufferPanel.BeginBufferDraw and TBufferPanel.EndBufferDraw before and after you read the bitmap.
https://github.com/salvadordf/OldCEF4De ... l.pas#L254
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Resolution in OSR Browser

Post by andreykrasnodar »

I found the solution. To decrease screen size twice you should make 2 cycles.
1st from 0 to screen height (maybe screen height minus 1, does not matter) with skipping every 2nd line
2nd from 0 to screen width with moving 4 bytes (one pixel) from Chromium's buffer into PaintBox32's buffer and skipping next 4 bytes.
I have decreased my screen 4x. The code is (but it will not work in yours projects)

Code: Select all

  for j := 0 to height - 1 do       //построчный проход
  begin
    for i := 0 to (width) do        //каждый байт строки
    begin
        src := @PByte(buffer)[(width*j*4+i)*16];
        dst := @PByte(Bits)[(width*j+i)*4];
        Move(src^, dst^, 4);
    end;
  end;
But the next strings of code is

Code: Select all

        PaintBox.Flush(Rect(dirtyRects[j].x, dirtyRects[j].y,
        dirtyRects[j].x + dirtyRects[j].width,  dirtyRects[j].y + dirtyRects[j].height));
        finally
        Unlock;
        PaintBox.Canvas.Unlock;
I really do not know what are dirtyrects and how to repaint only rects that was changed.
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Resolution in OSR Browser

Post by salvadordf »

The dirtyrects are the bitmap areas that need to be repainted.

The SimpleOSRBrowser uses that information to update the bitmap :
https://github.com/salvadordf/OldCEF4De ... r.pas#L456
Post Reply