Jump to content

at3s

Members
  • Content Count

    68
  • Joined

  • Last visited

Posts posted by at3s


  1. 15 hours ago, Cristian Peța said:

    You are using examples from others that doesn't work or doesn't work in your case.

    Maybe it's time to read the documentation of that printer, understand it and do it right.

     

    From what I understood reading a little Nicholas Piasecki's article is that you need to send binary data. Not ASCII.

    And from your code it's clear that you need (like in Nicholas Piasecki's article) a monochrome, one bit per pixel image. In top-bottom and right-left order. This is binary data. A sort of simplified PCX graphic format (long time ago I wrote a little procedure to save TBitmap to PCX format).

     

    Your don't need SendString(AValue: String) function. Use directly LSockect.SendData() instead. And don't use String but TBytes like LSockect.SendData() is expecting.

     

    Actually Delphi code above should do exactly what Nicholas Piasecki did in his article using C#.

     

    Can you please send me in PM your procedure of saving TBitmap to PCX format?


  2. On 2/15/2021 at 3:36 PM, Alex40 said:

    I am glad to tell you that we finally managed to fix the issue with the missing libs for the Android Service. 

     

    The Service.template.java file was causing this problem. It is generated when service is built.

     

    The file was outdated, below you will find the difference in the files:

     

    NEW:

    @Override
    public void onCreate() {
    libraryName = "lib" + baseLibraryName + ".so";
    super.onCreate();
    ProxyService.onCreate(this, libraryName);

     

    OLD:

    @Override
    public void onCreate() {
    libraryName = getApplicationInfo().nativeLibraryDir + "/lib" + baseLibraryName + ".so";
    super.onCreate();
    ProxyService.onCreate(this, libraryName);

     

    To be sure you have the latest version of the template java file, named "SERVICENAME.template.java" - when you upgrade to higher version of Delphi, just delete the file from the Service project folder and build the Service again, so the Delphi Compiler generates the latest one. If you have custom settings there, you will have to include them again in the new file!

     

    Regarding the OpenSSL libraries issue - I haven't tried to set their lib path the same way as the service does, but as far as they work in the Document path, I am fine with that.

     

    You can see as well the difference between the old and the new file in the screenshot below:
     

    image_2021_02_15T08_41_58_434Z.png

    Probably I have similar issue - application is freezing on splash screen in devices with the 64-bit system.

    I'm using libssl.so v 1.0.2r.

    The path is defined in an application in this way:

    IdOpenSSLSetLibPath(TPath.Combine(TPath.GetDocumentsPath, 'lib/arm64'));

    And file deployes in .\assets\internal\lib\arm64 folder.

    Where can I find that "SERVICENAME.template.java" file?

    It seems, I have not it.


  3. What is a way in Delphi FMX application to apply changes in SQLite database.

    F.e., there is an application v 1.0 in PlayMarked with the SQLite database v 0.1.

    New version 1.1 of an application comes with the database v 0.2 where was added new table, removed one field etc.

    How Delphi do (or not do and you did it instead) those migration work?

    When I was developing an application in Xamarin, there was a tool and it generated a "migration" script based on changes in DB classes, then Entity framework did all hard work.


  4. 14 hours ago, Remy Lebeau said:

    It really depends on the format that the ESC/POS is expecting.  It might be as simply as using TBitmap.SaveToStream() to save to a TBytesStream, and then using the stream's Bytes and Size properties.  Or it may be more complex, like having to extract the individual pixels, like that other code is doing.  You are going to have to provide more details about your particular situation.

    Here is my code. It's mostly the same as is in the sources here or here.

    And I'm getting the same result with the horizontal blank lines as here.

     

    uses
      System
      , System.SysUtils
      , System.UITypes
      , FMX.Graphics
      ;
    
    type
      TRgbTriple = packed record
        // do not change the order of the fields, do not add any fields
        Blue: Byte;
        Green: Byte;
        Red: Byte;
      end;
    
    // ---------------------------
    
    procedure TThermalPrinter.SendString(AValue: String);
    var
      SND: TBytes;
    begin
      SND := TEncoding.ASCII.GetBytes(AValue);
      LSockect.SendData(SND); // send data to the printer
    end;
    
    procedure TThermalPrinter.DoSetLineSpacing(AValue : integer);
    begin
     if (AValue = 0) then begin
       SendString(#$1B#$32{, false});  //Resetset to default
     end else begin
       SendString(#$1B#$33 + AnsiChar(AValue){, false});
     end;
    end;
    
    procedure TThermalPrinter.DoPrintBitmap(const ABitmap : TBitmap; const  BitsPerSlice : Byte);
    const
     Threshhold = 127;
    type
     TBitArray = array of boolean;
     TRGBTripleArray = ARRAY[Word] of TRGBTriple;
     pRGBTripleArray = ^TRGBTripleArray; // Use a PByteArray for pf8bit color.
    var
     BMPData: TBitmapData;
     vCol : integer;
     vRow : integer;
     vIndex : integer;
     vSliceIndex : integer;
     vBytePos : integer;
     vBitPos : integer;
     vOffset : integer;
     vLuminance : integer;
     vLine: pRGBTripleArray;
      vPixel: TAlphaColor;
     vDots: TBitArray;
     vSlice : Byte;
     vBit : Byte;
     vTmpBit: Byte;
     vVal: boolean;
     vTempStr : string;
    begin
     if not Assigned(ABitmap) then exit;
    
     ABitmap.Map(TMapAccess.Read, BMPData);
     try
        SetLength(vDots, (ABitmap.Height * ABitmap.Width));
        vIndex := 0;
    
        for vRow := 0 to ABitmap.Height-1 do
        begin
          for vCol := 0 to ABitmap.Width-1 do
          begin
            vPixel := BMPData.GetPixel(vCol, vRow);
            vLuminance := Trunc((TAlphaColorRec(vPixel).R * 0.3)  + (TAlphaColorRec(vPixel).G * 0.59) + (TAlphaColorRec(vPixel).B * 0.11));
            vDots[vIndex] := (vLuminance < 127);
            Inc(vIndex);
          end;
        end;
    
       DoSetLineSpacing(24);
       SendString(' ');
    
       vOffset := 0;
       while (vOffset < ABitmap.Height) do
       begin
        SendString(#$1B'*'#33 + AnsiChar(Lo(ABitmap.Width)) + AnsiChar(Hi(ABitmap.Width)){, false});
    
         vTempStr := '';
         for vCol := 0 to ABitmap.Width-1 do begin
           for vSliceIndex := 0 to 2 do begin // Remember, 24 dots = 24 bits = 3 bytes.
             vSlice := 0;
             for vBit := 0 to 7 do begin
               vBytePos := (((vOffset div 8) + vSliceIndex) * 8) + vBit;
               vBitPos := (vBytePos * ABitmap.Width) + vCol;
    
               vVal := false;
               if (vBitPos < Length(vDots)) then begin
                 vVal := vDots[vBitPos];
               end;
    
               if vVal then
                 vTmpBit := 1
               else
                 vTmpBit := 0;
               vSlice := vSlice or (vTmpBit shl (7 - vBit));
             end;
    
             vTempStr := vTempStr + AnsiChar(vSlice);
           end;
         end;
    
         Inc(vOffset, 24);
         SendString(vTempStr + #13#10);
       end;
    
       DoSetLineSpacing(0);
       SendString(' ');
     finally
        vDots := nil;
        ABitmap.Unmap(BMPData);
     end;
    end;

     


  5. 1 hour ago, weabow said:

    I use for Windows, Mac, IOs, Android and Linux TMS FNC UIpack, which contains FNC Core, which contains a pdf lib. Do NOT take FMX UI Pack if interested, as recommanded.

     

    I runs fine, very fast (2 seconds for 58 pages on Windows). You can draw, print texts and pictures, embed fonts.

     

    Very great tool.

     

    It's here...

     

    In attachment, an example with pictures in png, drawings (the targets), and texts.

    tms-fnc-pdf-lib.pdf

    Thanks. It sounds interesting.

     

    It seems I did not describe my topic clear.

    I'm interesting rather in a way how to send a PDF file from Android\iOS device to the printer connected to this device.


  6. 10 minutes ago, emailx45 said:

    please follow the links above.

    search in my profile my post about use of PERMISSIONS on Android. with sources tested.

     

    hug

    Based on topic "Runtime permissions in Android (new in Delphi 10.3)", do you think I have to grant ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions as well?

    Otherwise I do not see any differnces I already define in an application.


  7. Actually problem becomes in Android 10, in Android 6 I have so fine.

    I just have developed a form which shows folders and files in

    TPath.GetSharedPicturesPath

    directory.

    I have ask to grant READ_EXTERNAL_STORAGE permission for application, it is properly granted, checked in system.

    But 

    TDirectory.GetDirectories(TPath.GetSharedPicturesPath, '*')

    returns an empty list of folders as well as 

    TDirectory.GetFiles(TPath.GetSharedPicturesPath)

    returns an empty list of files in Android 10.

    Even I get a level up folder.

    Any idea?


  8. 9 minutes ago, Anders Melander said:

    No, not using a standard TPopupMenu. The menu loop is being handled by Windows (via the TrackPopupMenu API function) and you do not have any control of how it behaves - and that's how it should be; Altering the behavior of something like a menu just leads to poor usability. The fact that you've had to resort to keyboard & mouse hooks should be a hint that they don't want you messing with it.

     

    I suggest you display a non-modal form instead. You can easily make that behave like a popup menu, with your custom behavior, without raping the system.

    Thank you, it sounds reasonable.


  9. I'd like to realize a multiselection in Popup Ctrl+<Mouse click>.

    I've owerwrite a TPopupList.WndProc in recreated PopupList object and defined mouse and keyboard hooks on popup.

    So I able to mark an item as selected (checked) in popup by pressing space button, but I'm not able to make it working with the Ctrl+<Mouse click> - popup always closes.

     

    Keyboard hook:

    function PopupMenuKeyboardHookProc(Code: Integer; wParam : WPARAM; lParam : LPARAM): Longint; stdcall;
    begin
      try
        if (Code = HC_ACTION) and (wParam = WM_KEYUP) then
        begin
          if PKBDLLHOOKSTRUCT(lParam)^.vkCode = VK_SPACE then
          begin
            if Assigned(PopupList) then
            begin
              PostMessage(PopupList.Window, WM_POPUP_SPACE_KEY_MINE, wParam, lParam);
              wParam := WM_NULL;
              lParam := 0;
            end;
          end;
        end;
      finally
        Result := 0; 
      end;
    end;

    I tries to process WM_LBUTTONDOWN and WM_LBUTTONUP messages, but without success, popup anyway receives WM_MENUSELECT message with the (Msg.MenuFlag = $FFFF)and(Msg.Menu = 0)), so it closes.
    end;

    How to catch it?


  10. 6 minutes ago, Dave Nottage said:

    Yes - are you perhaps using an older version of the Grijjy Error Reporting code? The error in question was happening before they updated this unit:

     

    https://github.com/grijjy/JustAddCode/blob/master/ErrorReporting/Grijjy.ErrorReporting.pas

     

    Otherwise, you'd need to detail exactly what you're compiling and perhaps include a reproducible example.

     

     

    Exactly! I'm using this unit. But I do not see any newer versions of this unit on github.


  11. 23 minutes ago, emailx45 said:

    my tip:

    • my tip main: DONT INSTALL THE SOFTWARES IN FOLDERS WITH LONG-NAME
      • reason: PATH variable on system operating!
      • mainly software like SDK/NDK that use many "tree-nodes" in your default "installation"
    • Android SDK/NDK is not "installed" in your system... just unziped and copyed to your disk!
      • then, you can copy it from any other pc with same versions and updates (if necessary) using SDKManager.exe in SDK Windows folder
    • As "IT" is not installed, just copyed, then, you can have it in any disk or folder
      • try copy to another place with shor-name, like:  C:\SDKs\.... or D:\SDKs\...
      • if you want try, you can just delete this whole directory (..\\AndroidNDK-21-21.0.37889.9797\) or copy to another place with shor-name, like:  C:\SDKs\.... or D:\SDKs\...
      • try dont use this "horrible-root-name" AndroidNDK-21-21.0.37889.9797 -- change it for: NDK21  (NDK is Android, 21 is Sydney)
        • same for SDK for MSWindows used by Android!
    • for last, use your IDE (menu SDK Manager) to re-config your paths for Android setup.

    Last note: RAD 10.4 Sydney is a traged! if possible stay on RAD 10.3.3 Rio

    Thanks, but your propositions did not help: I've created a hard link D:\SDKs\SDK-25 and D:\NDKs\NDK-21, but I still get the same error.
     

    Quote


    [DCC Error] E2597 D:\NDKs\NDK-21\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: error: cannot find -lgnustl_static

     

     

    Any idea?


  12. An Android application compiles fine in Delphi 10.3.3 Rio, but after I've migrated to Delphi 10.4 Sydney I started to get an error:

     

    Quote

    [DCC Error] E2597 C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidNDK-21-21.0.37889.9797\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: error: cannot find -lgnustl_static

     

    Has anyone something similar?


  13. 20 hours ago, Kryvich said:

    Yes, I see the same. It's strange, because when I generate tom_TLB.pas, even in Windows XP there is Spacing property in ITextFont interface. After doc.Selection.Font.Spacing := ASpaces, the Spacing property is actually returns the new value, but the edit control is not displaying as expected.

    Exactly. I even tried to copy and load different MsftEdit.dll versions in Windows 7, but without success.


  14. 6 minutes ago, FPiette said:

    Maybe a new Win8 or Win10 feature not supported by Win7.

     

    It seems so.

     

    On 10/18/2020 at 7:32 PM, Kryvich said:

    You need RichEdit50W, but TRichEdit utilize Riched32.dll / Riched20.dll, not MsftEdit.dll.

     

    In my program I used JvRichEdit from JVCL library, modified to utilize MsftEdit.dll instead of Riched32.dll. Updating the component version also significantly speeds up a loading of large RTF files.

    Does JvRichEdit's Spacing work fine in all Windows versions (Win7 x32, Win XP f.e.)?

×