Recent

Author Topic: New version of BGRABitmap  (Read 288106 times)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #270 on: November 13, 2016, 12:06:01 am »
Hi josh,

Excellent, thanks!! :D It may be a problem with TCanvas in general as I got the same result with TForm.Canvas.

I'm having trouble loading your moded project though. I didn't have bgracontrols installed, and am having trouble figuring out how to install it. I thought I had it, but am getting errors. I seem to have trouble with packages.  :(

Maybe there is another workaround...

Cheers,
VTwin
 
« Last Edit: November 13, 2016, 12:11:41 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: New version of BGRABitmap
« Reply #271 on: November 13, 2016, 12:28:53 am »
Hi

My fault, I was trying some other controls to make sure they worked as well, and forgot to take out the dependencies.

Attached project that should have all non used dependencies removed.

I tried to get tpl_scope component to work on osx, and gave up after a while; this also uses tpaintbox. I also was using a paintbx to render the wave form of an audio file; this worked fine in windows; but on osx it was intermittent; some times it would render and sometime it would display nothing; I even made it create a file of the ordinates it should be rendering;  just to make sure the value were in range and all was fine; so I concluded an intermittent bug when drawing lines within pb; and as the values were sent were fine further concluded it had something to do with colors not being drawn correctly.  Last time I checked bugtracker; there were a few open paintbox issues.

Hopefully these bugs/issues will get solved soon.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #272 on: November 13, 2016, 02:00:33 am »
Hi josh,

Many thanks, I can now open the project. But when I hit the line:

BPR.Picture.Bitmap:=FBMPR.Bitmap;

I get:

Project project1 raised exception class 'FPImageException' with message:
Failed to create bitmap handle

Maybe I screwed something up? I reinstalled Lazarus just in case, but no dice yet.

Cheers,
VTwin

“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #273 on: November 13, 2016, 02:17:52 am »
I'm having luck with this:

Code: Pascal  [Select][+][-]
  1. imgR.Picture.Bitmap.SetSize(w, h);
  2. fBmpR.Draw(imgR.Picture.Bitmap.Canvas, 0, 0, true); {EDIT}

where imgR is a TImage. Seems confusing, but works. :)
« Last Edit: November 13, 2016, 02:56:26 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: New version of BGRABitmap
« Reply #274 on: November 13, 2016, 02:51:34 am »
Hi
Thats odd, I just downloaded the project I uploaded and compiled and run ok.

Maybe its Lazarus and FPC differences.

I am using FPC 3.1.1 and Laz 1.7 (SVN 53325)  Think its a couple of days old

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #275 on: November 13, 2016, 03:01:04 am »
Hi josh,

Yes seems odd. It is possible I messed something up, but think I have a clean install. I'm on the last stable release, FPC 3.0.0 and Laz 1.6.0.

Thanks for checking, I appreciate your help!

Cheers,
VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: New version of BGRABitmap
« Reply #276 on: November 13, 2016, 03:32:29 am »
just thought,

Can you check the project dependencies in Project Inspector, its possible that there may be an error in the differnce in location of BGRABITMAP, If it appears with a line through it; remove the dependency and then add your bgrabitmap dependency in.
Also maybe worth checking your project options are all set, ie Darwin, Compile for i386 and widgetset is set to Carbon. These can change sometimes between versions.

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #277 on: November 13, 2016, 02:45:23 pm »
I don't see anything strange, no red lines. Just in case I removed BGRABitmapPack using the Project Inspector, and then added in the one in the directory containing 9.2.2 bgrabitmap. No change. Widgetset is Carbon, Darwin, i386.

However, I copied the code using TImage into my original program where I encountered the problem, and am still getting the old behavior with odd colors. %)

EDIT

In my original program I get:

Warning: other unit files search path (aka unit path) of "MyProg" contains "/Users/.../bgrabitmap", which belongs to package "BGRABitmapPack"

Confused, maybe this is a problem?
« Last Edit: November 13, 2016, 03:11:01 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: New version of BGRABitmap
« Reply #278 on: November 13, 2016, 03:32:42 pm »
In my original program I get:
Warning: other unit files search path (aka unit path) of "MyProg" contains "/Users/.../bgrabitmap", which belongs to package "BGRABitmapPack"
Confused, maybe this is a problem?

Maybe this is due to the fact that in the latest trunk LazPaint and Bgrabit stuff is now separated?  You probably have an older install somewhere of the LazPaint stuff.
Re-installing both and cleaning out the directories first might help.
https://github.com/bgrabitmap/bgrabitmap
« Last Edit: November 13, 2016, 03:36:25 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #279 on: November 13, 2016, 05:24:22 pm »
Thaddy, Thanks. Yes, I had an extra reference. I think it was because I had bgrabitmappack in "Required Packages", AND had the bgrabitmap directory in the Paths "Other unit files". Got that cleared up.

It is finally working!!! :D Using TImage was the trick as josh suggested. Hooray!!

I'll file a bug report. Many thanks all.

Cheers,
VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #280 on: November 13, 2016, 05:40:24 pm »
Hello VTwin,

It is surprising that drawing on Canvas doesn't work. Can you try the following test program to check what happens when using different formats with TRawImage?

Here is the result on Windows10.
Conscience is the debugger of the mind

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #281 on: November 13, 2016, 07:17:42 pm »
Hello circular,

I get a bad access exception, so:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.PaintBox4Paint(Sender: TObject);
  2. var bmp: TBitmap;
  3. begin
  4.   bmp := MakeBitmapSample(Label4.Caption);
  5.   //PaintBox4.Canvas.Draw(0,0,bmp);
  6.   bmp.Free;
  7. end;


but here is the form with the other three.

Cheers,
VTwin

I'm on OS X 10.10.5 at the moment.
« Last Edit: November 13, 2016, 07:19:43 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #282 on: November 13, 2016, 07:35:38 pm »
On Ubuntu 14.04 there is no exception, all four are the same with correct colors.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #283 on: November 13, 2016, 08:27:48 pm »
@VTwin:
Thanks. Ok, maybe the strange colors happen when there is no alpha channel. What happens if you remove the alpha channel:
Code: Pascal  [Select][+][-]
  1.   with raw.Description do
  2.   begin
  3.     Init;
  4.     Format := ricfRGBA;
  5.     Depth := 24; // used bits per pixel
  6.     Width := imageWidth;
  7.     Height := imageHeight;
  8.     BitOrder := riboBitsInOrder;
  9.     LineOrder := riloTopToBottom;
  10.     BitsPerPixel := 32;
  11.     LineEnd := rileDWordBoundary;
  12.     RedPrec := 8;
  13.     GreenPrec := 8;
  14.     BluePrec := 8;
  15.     AlphaPrec := 0; //no alpha channel
  16.     RedShift := (pos('R',channelOrder)-1)*8;
  17.     GreenShift := (pos('G',channelOrder)-1)*8;
  18.     BlueShift := (pos('B',channelOrder)-1)*8;
  19.     AlphaShift := (pos('A',channelOrder)-1)*8;
  20.     {$IFDEF ENDIAN_BIG}
  21.     ByteOrder := riboMSBFirst;
  22.     RedShift := 24-RedShift;
  23.     GreenShift := 24-GreenShift;
  24.     BlueShift := 24-BlueShift;
  25.     AlphaShift := 24-AlphaShift;
  26.     {$ELSE}
  27.     ByteOrder := riboLSBFirst;
  28.     {$ENDIF}
  29.   end;
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #284 on: November 13, 2016, 08:29:46 pm »
when I hit the line:

BPR.Picture.Bitmap:=FBMPR.Bitmap;

I get:

Project project1 raised exception class 'FPImageException' with message:
Failed to create bitmap handle
This is a problem I've had before. In my memory, it is related to the fact that when you assign a bitmap like that, it becomes a shared bitmap and that causes some problems. You can use TBGRABitmap.MakeBitmapCopy to have a bitmap you can safely assign.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018