Jump to content

at3s

Members
  • Content Count

    46
  • Joined

  • Last visited

Everything posted by at3s

  1. Actually I'm looking for a function which could convert TBitmap to TBytes for printing in ESC/POS Thermal Printer. I'm trying to make working a code from here, but also got an effect as on the author picture - white lines and not correct text on an image as well. Has someone a working code?
  2. You're awesome! You've fixed my problem. Thanks a lot.
  3. As you can see in my sample, I don't send a string to the POS printer but rather TBytes. Probably a string type of AValue parameter of SendString procedure twice confusing you. Sure, it AValue is not properly populated, SendString procedure shall send something weird. But I got an image as output on printer, but it's just cutting by horizontal lines. And this Lazarus implementation of Nicholas Piasecki's code doesn't work for me as well.
  4. I used a lot of specification for ESC\POS printer. Actually I tried to make my code working in RawBT application (something like virtual ESC\POS printer) and now I'm trying to use GOOJPRT PT-210 device. I did not find a specification for this model of printer. but I require more general solution to be able to print a receipt from my Android application.
  5. 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?
  6. 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?
  7. 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.
  8. 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.
  9. at3s

    SQLite migration tool in FMX application

    Thanks, FDBatchMove seems like a good start point.
  10. 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;
  11. What is the best approach to do this? I know, that there is not a simple solution in the FireMonkey for Android\iOS.
  12. Yes, ShowShareSheetAction is a good option.
  13. 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.
  14. I'm agree with you. But I have not any special in my project setup settings. Any newly created FMX project shall have mostly the same AndroidManifest.template.xml file. So the topic's issue shall be there as well.
  15. Here is solution: [RSP-30935] Android 10 delphi 10.4 camera and gallery doesn't work - Embarcadero Technologies When I added android:requestLegacyExternalStorage="true" into 'AndroidManifest.template.xml', application started to be working so fine in Android 10. Now I'm interesting what shall be in Android 11...
  16. 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.
  17. It makes sense. But TPath.GetSharedPicturesPath returns /storage/emulated/0/Pictures/ I need to be able to show pictures from device in my form.
  18. Yes, it's checked. TDirectory.GetDirectories anyway returns an empty list for /storage/emulated/0/
  19. 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?
  20. Thank you, it sounds reasonable.
  21. 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: Has anyone something similar?
  22. I'm sorry, but where I have to change it?
  23. Exactly! I'm using this unit. But I do not see any newer versions of this unit on github.
  24. 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. Any idea?
×