BGRABitmap textout does not work in simple console app lazarus / 39-Graphics ---------------------------------------------------------------------- phampl · 2019-03-28 20:47 When I create FP console application on Win7/64bit, make BGRABitmap and try to insert text, I get an error This is the code: program project1; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses classes, sysutils,     BGRABitmap, BGRABitmapTypes;var    bmp: TBGRABitmap;    x,y: integer;    p: TBGRAPixel;begin  bmp := TBGRABitmap.Create(800,600, BGRAblack);  p:=tbgrapixel.New(200,0,100);  bmp.fontname:='Arial';  bmp.fontheight:=20;  bmp.TextOut(200,200, 'help',p,taleftjustify);    // here I get the error  bmp.SaveToFile('pokusbgra.png');  bmp.free;end. and this is the console error message: QuoteAn unhandled exception occurred at $0000000100168537: EAccessViolation: Access violation   $0000000100168537 line 405 of ../../../../../lazarus/fpc/3.0.4/units /x86_64-win64/bgrabitmap/bgratext.pas   $000000010016872E line 534 of ../../../../../lazarus/fpc/3.0.4/units /x86_64-win64/bgrabitmap/bgratext.pas   $000000010016A4C2 line 1074 of ../../../../../lazarus/fpc/3.0.4/unit s/x86_64-win64/bgrabitmap/bgratext.pas   $000000010016AC59 line 1168 of ../../../../../lazarus/fpc/3.0.4/unit s/x86_64-win64/bgrabitmap/bgratext.pas   $000000010007E5F2 line 4069 of ../../../../../lazarus/fpc/3.0.4/unit s/x86_64-win64/bgrabitmap/bgradefaultbitmap.pas   $0000000100037E19 line 1913 of ../../../../../lazarus/fpc/3.0.4/unit s/x86_64-win64/bgrabitmap/bgracustombitmap.inc   $000000010000185A line 15 of project1.lpr   $0000000100001896   $0000000100013F93   $0000000100014A91   $000000007755571D   $00000000777B385D ---------------------------------------------------------------------- lainz · 2019-03-28 21:55 I think you need to install package BGRABitmap4nogui to use it in console applications. ---------------------------------------------------------------------- phampl · 2019-03-29 07:35 When I insert the bgrabitmappack4nogui.lpk into the project, I get compilation error in BGRABitmapTypes.pas line 1165: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  ResourceTypes: array[1..7] of TResourceType =   ((ext: 'CUR'; code: RT_GROUP_CURSOR),   // this RT... constants are unknown    (ext: 'BMP'; code: RT_BITMAP),    (ext: 'ICO'; code: RT_GROUP_ICON),    (ext: 'DAT'; code: RT_RCDATA),    (ext: 'DATA'; code: RT_RCDATA),    (ext: 'HTM'; code: RT_HTML),    (ext: 'HTML'; code: RT_HTML));  Those constants are defined in BGRAWinresource which is not included here. If I include it, there is another error at the same place: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i bgrabitmaptypes.pas(1165,39) Error: Incompatible types: got "ShortInt" expected "PChar" ---------------------------------------------------------------------- Ñuño_Martínez · 2019-03-29 12:35 Do not include the lpk file in the project:  you should install the package in to Lazarus instead.  Do it from menu "Packages > Install/uninstall packages..." or "Packages > Open package file (.lpk)..." ---------------------------------------------------------------------- lainz · 2019-03-29 18:57 Quote from: phampl on March 29, 2019, 08:35:06 amWhen I insert the bgrabitmappack4nogui.lpk into the project, I get compilation error in BGRABitmapTypes.pas line 1165: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  ResourceTypes: array[1..7] of TResourceType =   ((ext: 'CUR'; code: RT_GROUP_CURSOR),   // this RT... constants are unknown    (ext: 'BMP'; code: RT_BITMAP),    (ext: 'ICO'; code: RT_GROUP_ICON),    (ext: 'DAT'; code: RT_RCDATA),    (ext: 'DATA'; code: RT_RCDATA),    (ext: 'HTM'; code: RT_HTML),    (ext: 'HTML'; code: RT_HTML));  Those constants are defined in BGRAWinresource which is not included here. If I include it, there is another error at the same place: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i bgrabitmaptypes.pas(1165,39) Error: Incompatible types: got "ShortInt" expected "PChar"  Please report it in issues page https://github.com/bgrabitmap/bgrabitmap/issues ---------------------------------------------------------------------- phampl · 2019-03-31 18:33 OK, Ihave reported it as an issue, but now there is a question. I have console app using BGRABitmap to create some image. How can I put some text into it for now? Is it possible to use some other type of bitmap, create the text in it and then copy the text rectangle into the BGRABitmap? I am not quite familiar with the FPC-Lazarus solutions and after searching in guides I did not find a way which i could understand enough. The BGRA is easy for me to use RGB values directly without any palette. Is there any simple way for it, as I don't know when the issue could be repaired and I need some solution quite soon. I tried the fpimage but could not use RGB directly, only through palette. ---------------------------------------------------------------------- lainz · 2019-03-31 19:56 Include and initialize the LCL and use regular BGRABitmap on the console application. I don't know how that can work without forms, someone else must know. ---------------------------------------------------------------------- phampl · 2019-04-01 07:47 Great, I just added "uses Interfaces" and it started to work immediately. Thank you very much, Lainz! ---------------------------------------------------------------------- circular · 2019-10-22 16:09 Some update about it: the missing constants are indeed missing for fpGUI on Windows, maybe due to a relatively recent change in System unit. I have applied a workaround (on dev branch) so that BGRABitmap compiles fine in this case. Regarding text, you need to specify a directory where some fonts are. You need to have Arial in it at least. See test4fpgui example: https://github.com/bgrabitmap/bgrabitmap/tree/master/test/test4other ---------------------------------------------------------------------- upsidasi · 2019-12-11 11:46 Those constants are still missing if you try to compile 'test4nogui.lpi' on Windows. Both on dev and v10.6.4 branches. Probably due to the fact that they are defined only if "{$IFDEF BGRABITMAP_USE_FPGUI}". ---------------------------------------------------------------------- circular · 2019-12-11 17:50 Oh I see. I've added the case of noGUI on dev branch. ---------------------------------------------------------------------- upsidasi · 2019-12-12 09:54 Thank you for your quick response. But your code does not work: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$IFDEF defined(BGRABITMAP_USE_FPGUI) or defined(BGRABITMAP_DONT_USE_LCL)}{$IFDEF MSWINDOWS}const  RT_BITMAP = MAKEINTRESOURCE(2);  RT_RCDATA = MAKEINTRESOURCE(10);  RT_GROUP_CURSOR = MAKEINTRESOURCE(12);  RT_GROUP_ICON = MAKEINTRESOURCE(14);  RT_HTML = MAKEINTRESOURCE(23);{$ENDIF}{$ENDIF}  It seems to work if I use $IF instead of $IFDEF. ---------------------------------------------------------------------- circular · 2019-12-12 19:38 Oops that's right. I've put $IF instead. We're getting there! ---------------------------------------------------------------------- upsidasi · 2019-12-13 04:43 It works like a charm now, thank you very much! ---------------------------------------------------------------------- circular · 2019-12-22 19:28 You're welcome. Thanx for the feedback