![]() If they all inherited from the TImage class instead you wouldn't need to do any converting to load and alter an image. are all inheriting from the TGraphic base class. Classic OOP would, for instance, create a deck of cards class and then inherit from that to produce a blackjack game and a poker class would similarly inherit from the deck class. You have one power function that takes a parameter that raises a number to the specified power. ![]() ![]() For instance, you don't want one function that returns squares of a number, another for cubes, etc. In normal development, you make that one function and supply a parameter. Having lots of methods that all do the same thing with a slight twist isn't a good idea. The above book will explain that too, but ask instead: Why should it? Pick up any book on software design and it will explain why that is not a good idea. When you're using Pixels to manipulate the whole bitmap then the optimizations in the code become pretty pointless and only obfuscates the algorithm. For anything serious you have to mess with the raw DIB data directly - or use something like Graphics32 which does that for you. They would just have to convert to/from TBitmap internally to do so anyway.ītw, using TCanvas.Pixels is extremely slow but fine for learning and very minor drawing tasks. TBitmap can wrap these with a TCanvas and thus provide access to most of the functionality of the GDI through the canvas.Īdditionally almost all other formats can convert to and from TBitmap so there's no reason why all the other formats should duplicate the functionality in TBitmap/TCanvas/GDI. ![]() TBitmap on the other hand implements the BMP encoding and is internally represented as a native Windows DIB or DDB. They are not optimized to handle image manipulation. Their internal representation is optimized to handle the features of the file format. The sole purpose of TPNGImage, TJPEGImage and TGIFImage is to read, write and display these formats. Do you know what the reason might be for that design decision?īMP, PNG, JPEG, GIF etc. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |