-
Content Count
1291 -
Joined
-
Last visited
-
Days Won
28
Posts posted by Sherlock
-
-
The common link is clear but the evolution of use and meaning is just baffling to me.
-
On 2/3/2023 at 8:04 PM, Lars Fosdal said:på gammelnorsk
ROFL....sorry, but in german "gammel" means "rotten". This is just too funny how related and then again not our languages are.
-
3 hours ago, David Heffernan said:No.
To elaborate on this correct and concise answer: One should only fix things that a really broken or occur during the life cycle of the software. You simply cannot think of all eventualities - one of them being: will there still be a Delphi compiler in the year 9999? If not, how can I make sure that my code can still be compiled? Are we all gonna die? OMG! Panic! Enter into catatonic state now.
To use popular acronyms: This is both YAGNI and KISS.
-
So I finally tried it myself, inspired by a fairly new SO question.
Me: Using the Delphi language, explain how to turn a large image into many smaller ones and tile them
QuoteIn Delphi, you can split an image into smaller tiles using the TBitmap class. Here's an example of how to do it:
uses System.Types, Vcl.Graphics; procedure SplitImage(const SourceImage: TBitmap; TileSize: TSize; Tiles: TArray<TBitmap>); var i, j: Integer; DestRect: TRect; begin SetLength(Tiles, (SourceImage.Width div TileSize.cx) * (SourceImage.Height div TileSize.cy)); DestRect.Size := TileSize; for j := 0 to SourceImage.Height div TileSize.cy - 1 do begin for i := 0 to SourceImage.Width div TileSize.cx - 1 do begin DestRect.Left := i * TileSize.cx; DestRect.Top := j * TileSize.cy; Tiles[i + j * (SourceImage.Width div TileSize.cx)].Canvas.CopyRect(Rect(0, 0, TileSize.cx, TileSize.cy), SourceImage.Canvas, DestRect); end; end; end;
This function takes a
SourceImage
TBitmap, aTileSize
TSize that specifies the size of each tile, and an emptyTiles
TArray of TBitmap that will be filled with the resulting tiles.It first sets the length of
Tiles
to the number of tiles that will be created, then iterates through each row and column of tiles, copying aTileSize
rectangle from theSourceImage
to each tile in theTiles
array.My follow up question then crashed the thing:
How can I make sure only the tiles visible on the screen will be painted?
☠️
Then I tried the same question again, hoping a different follow up would not crash...
It came up with a different answer:
QuoteHere's an example code in Delphi to divide a large image into smaller parts and then tile them:
uses Graphics; procedure SplitImage(Source: TBitmap; TileWidth, TileHeight: Integer; Dest: TStrings); var x, y: Integer; Tile: TBitmap; begin Tile := TBitmap.Create; try Tile.Width := TileWidth; Tile.Height := TileHeight; for y := 0 to Source.Height div TileHeight - 1 do begin for x := 0 to Source.Width div TileWidth - 1 do begin Tile.Canvas.CopyRect(Rect(0, 0, TileWidth, TileHeight), Source.Canvas, Rect(x * TileWidth, y * TileHeight, (x + 1) * TileWidth, (y + 1) * TileHeight)); Dest.AddObject(Format('Tile_%d_%d', [x, y]), Tile); end; end; finally Tile.Free; end; end;
In this code,
Source
is the input image you want to split,TileWidth
andTileHeight
are the width and height of each tile, andDest
is aTStrings
object that will hold the names and bitmaps of the tiles.The
SplitImage
procedure creates a newTBitmap
object namedTile
and uses theCopyRect
method of the canvas to extract a portion of the source image and save it as a tile. The extracted tile is then added toDest
along with a name generated using theFormat
function.You can use the resulting
Dest
object to tile the images however you like.Well that looked easy enough but:
Me: The source should be assumed to be 40000 by 40000 pixels
Quotet's important to note that creating a
TBitmap
object with such a large size can result in performance and memory issues, as well as reaching the maximum limit for a bitmap's size. To avoid this, you may want to consider splitting the source image into multiple parts and processing each part separately, for example by using a loop and dividing the source image into smaller pieces each iteration.Additionally, you may also want to consider using a more efficient image format, such as JPEG or PNG, for the source image instead of a BMP. These formats support lossy or lossless compression, which can help reduce the memory usage and improve the performance of the application.
Thanks for that piece of well known information...why do you think I wanted to split the thing in the first place? So...
Me: Well the splitting part you have done, but assume the source is a 40000 by 40000 PNG
QuoteIn that case, you would simply need to load the PNG image into a
TBitmap
object before passing it to theSplitImage
procedure. Here's an example code to do that:uses Graphics, PNGImage; procedure LoadImage(const FileName: string; Source: TBitmap); var PNG: TPNGImage; begin PNG := TPNGImage.Create; try PNG.LoadFromFile(FileName); Source.Assign(PNG); finally PNG.Free; end; end; procedure TForm1.Button1Click(Sender: TObject); var Source: TBitmap; Tiles: TStringList; begin Source := TBitmap.Create; try LoadImage('large_image.png', Source); Tiles := TStringList.Create; try SplitImage(Source, TileWidth, TileHeight, Tiles); // Use Tiles as needed, for example to draw them on
Eagle eyed I spot the issue at once (never minding the snippet is unfinished):
Me: that is to large for a TBitmap
QuoteYou are correct, a
TBitmap
object with such a large size would likely result in performance and memory issues. To handle this issue, you could use a more efficient image processing library that is optimized for handling large images, such as the VCL Imaging Library (VCL.Imaging) or the Graphics32 library.With these libraries, you can read and process the image in a more efficient way, such as by reading the image data in chunks or using a tiling approach, which would allow you to process large images without running into memory or performance issues.
Here's an example code using the VCL.Imaging library to split a large PNG image into smaller tiles:
uses System.Classes, Vcl.Imaging.Jpeg, Vcl.Imaging.PNGImage; procedure LoadImage(const FileName: string; Source: TPngImage); begin Source.LoadFromFile(FileName); end; procedure SplitImage(Source: TPngImage; TileWidth, TileHeight: Integer; Dest: TStrings); var x, y: Integer; Tile: TPngImage; begin Tile := TPngImage.Create; try Tile.Width := TileWidth; Tile.Height := TileHeight; for y := 0 to Source.Height div TileHeight - 1 do begin for x := 0 to Source.Width div TileWidth - 1 do begin Tile.Canvas.CopyRect(Rect(0, 0, TileWidth, TileHeight), Source.Canvas, Rect(x * TileWidth, y * TileHeight, (x + 1) * TileWidth, (y + 1) * TileHeight)); Dest.AddObject(Format('Tile_%d_%d', [x, y]), Tile); end; end; finally Tile.Free; end; end; var Source: TPngImage; Tiles: TStringList; begin Source := TPngImage.Create; try LoadImage('large_image.png', Source); Tiles := TStringList.Create; try SplitImage(Source, TileWidth, TileHeight, Tiles); // Use Tiles as needed, for example to draw them on a form finally Tiles.Free; end; finally Source.Free; end; end;
In this code,
Source
is aTPngImage
object that holds the large image,TileWidth
andTileHeight
are the width and height of each tile, andDest
is aTStrings
object that will hold the names and PNG images of the tiles.The
SplitImage
procedure creates a newTPngImage
object namedTile
and uses theCopyRect
method of the canvas to extract a portion of the source image and save it as a tile. The extracted tile is then added toDest
along with a name generated using theFormat
function.OK, that looks nice, with one slight snag in the middle part:
Me: Width and Height are ReadOnly for a TPNGImage.
That got it to thinking quite bit, and it started to write something in the likes of "Yes, you are right, and here is how to get around that". Started to put together some code and crashed again... Oh, well. I guess it is not ready for my stupid questions. 🕵️♂️
-
Please also note that any "custom" Java snippets or Android specific code will not migrate without making a fuss.
-
1
-
-
2 hours ago, Rollo62 said:Of coarse competitors of hearing-aids might find ways to sue against such products.
Only if and when Sennheiser chooses to call them hearing aids themselves, but then they might get questions from other folks too. So I'm sure they will avoid using the term wherever they can....at least until they have all the necessary documentation. I mean 849 bucks is a steep price for ear buds, but quite competitive for mid-level hearing aids.
-
1
-
-
-
1 hour ago, Attila Kovacs said:I'm not sure how would it affect the "write a poem in norwegian" command
It would probably use "old norse".
-
1
-
-
That watch is a medical device, or rather it should be. Because in the end it is what the manufacturer says it is (intended use). So if you create a smart watch that monitors cardiac rhythms you have to formulate its intended use carefully. For example you might state it should be used by athletes and those who would like to be to keep an eye on their heart - then you're almost golden... almost, because you'll have to deal with foreseeable misuse, someone with a history of pathologic arrhythmia might think it clever to use this watch to warn them when something really bad happens to their heart - but since the watch or algorithms where designed with healthy users in mind it'll either alert constantly or never (I'm not really fit with cardiology, so I can't think of realistic examples). There is a lot of thought that has to go into this. And more standards...because this is a piece of hardware, you'll need to look into IEC 60601-1 and its more detailed offspring. I am sure however that someone has told your boss about all this or that he has asked someone about it.
As to your last question: The IEC 62304 is "merely" a software standard and to understand it fully you'll need to invest some time and/or take some classes such as this https://www.bsigroup.com/en-GB/medical-devices/training/Introduction-to-Medical-Device-Software-Training/ the cost of this particular course should give you an indication as to where the trip is going. Calculate roughly the same for a 13485 course - per person attending, mind you. Then you'll definitely need to know and use the IEC 14971, there are courses too i.e. https://www.bsigroup.com/en-GB/medical-devices/training/iso-14971-2019-risk-management-for-medical-devices/ Then your company should be fit to give it a go. By that time you have to find and auditor. That is a notified body (directly or indirectly accredited and certified by the government) who will check all documentation as I stated earlier. And they don't do this out of the goodness of their heart. Calculate at least 10k€ for this, once a year for the rest of the companies life. All in all prepare to invest around 50 k€ in "compliance" alone. Another really good summation can be found here: https://www.cognidox.com/medical-device-development-guide
-
I should correct my statement as to what is needed to market: Most important is the declaration of conformity, and how this was obtained, the "conformity assessment route". There are many ways to reach conformity, but some are actually the same... I have a german link to explain further...not english, sorry: https://www.johner-institut.de/blog/tag/konformitatsbewertung/
-
Is this still the case when you declare the type as well?
var combinedPath: string := TPath.Combine(ParamStr(0),'..\..\..\'); var curPath:string :=TPath.GetFullPath(combinedPath);
-
20 hours ago, TheOnlyOne said:...Plenty of reasons to perhaps look for a new employer...
That sounds dismal. What struck me though is this: How does this make any form of version management possible? If every developer has their own style they might be tempted to reformat code as they work on it, causing a multitude of changes and in essence a merging nightmare.
-
1
-
-
@Rollo62 HA! Nice! Johner Institute is my helper to get through this tedious process I can really recommend them.
-
1
-
-
There are plenty of applications created with Delphi, that are conform with 62304. My own application for example. 62304 does not demand the use of certain languages, it does however require extensive documentation. Documentation you should have anyway... Have you read anything concerning this standard? Wikipedia grants us a small glance at the implications: https://en.wikipedia.org/wiki/IEC_62304 I would suggest to consult more in depth literature and courses however. The subject is not trivial, especially the risk based decision model, that should be used in almost all aspects of the software life cycle. Auditors or accreditors as you call them, will not read your source code, as that is proprietary to you and your company. They will however read the entire technical documentation.
Most important is the market you want to sell your product, if it is Europe, you will need more that IEC 62304. You will need to adhere to the medical device regulation (MDR 2017/745) and that means you'll need to establish a company wide quality management system such as the ISO 13485. And you'll need certification before selling anything. All in all this will swallow up a ton of money before you can even start thinking about generating any revenue.
-
2
-
-
33 minutes ago, david_navigator said:Interestingly none of the code samples it's given me so far have worked "out of the box"
Well, there's your answer. And also why SO has banned AI generated answers. So...actually no need to start a new thread. Just chime in one of the other threads:
-
2
-
-
There has been a fix for the Win32 compiler. Perhaps a test run and a sign that there is something happening in Embarcaderoland: https://quality.embarcadero.com/browse/RSP-39812
-
It was called Eliza back then. ChatGPT is just Eliza on Steroids.
-
Almost every "call" is potentially dangerous. Asking for a language or a dialect of an existing language without potentially dangerous calls will leave you with nothing, hence the lack of answers from the people you contacted. It is up to you to find out what weaknesses a language has and how to either overcome them or, if to cumbersome, avoid the language altogether.
Then you also have to take into account the security issues the system running your software may have. Windows has quite the "rap sheet", when it comes to vulnerabilities. But still it is a solid OS to run your software on, if you are aware of these issues. You may choose to run in a browser...that in itself may expose you to new risks you'll have to learn about, risks that may even be specific to the OS running the browser, so you'll end up checking out combinations of browsers and OSes even over different versions, a ton of permutations to evaluate. And so far you haven't even looked at hardware. What about the USB ports on a standard PC? How can you verify that they are not misused? As you see cyber security is very expensive, thinking about what might go wrong is just the first step of many. Real security however is just an illusion, just like the idea of error free software. What you need to have is risk assessment together with a catalog of countermeasures and assess how useful or indispensable your software really may be. If the benefit-risk-ratio is acceptable, go ahead build your software, if not... I seem to have drifted of, sorry.
-
1
-
-
ChatGPT is way to verbose with its answers and takes forever to finally get to the point. I don't consider it fascinating, and I don't consider it to be an AI. It has had it's moments and those have been enough for one investor or another to inject money into the project or to actually assume they might be able to put it to use (Bing - imagine the loooong answers for a simple search).
In short ChatGPT is Eliza without the need to program responses but have responses stored in a DB filled by training.
-
You want to compare two binary files, if I understand correctly. Here is a program that does that: https://www.cjmweb.net/vbindiff/
-
No, it means you can install Skia4Delphi and use it in your project, and after following the steps pointed out to you, you can use "right to left" as originally expected.
-
1
-
1
-
-
Also keep in mind, if this software is supposed to be commercial you will have to look into encrypting the communication. TLS will have to be minimum.
-
1
-
-
On 12/14/2022 at 11:44 AM, Attila Kovacs said:First, you have to avoid sending emails to malformed email addresses.
I would have put that check into an SMTP server. And...surprisingly the good ones do that.
-
Given the complexity and the tendency of developers to always suggest some totally different approach
, here is my completely different suggestion. You seem to have the need to validate an e-mail address before storing it. How about sending a test mail before doing that. That way you get to birds with one stone: Verify the address, and get the permission to use it... a must have in Europe.
-
1
-
A comprehensive guide to Delphi programming language functions and procedures
in VCL
Posted
Those links seem quite harmless. It's just two sites translated from persian to english. Second link is pouyafars blog and the first is a forum. I don't see the immediate need to act. And translate.goog belongs to google.