Jump to content

peter2005

Members
  • Content Count

    6
  • Joined

  • Last visited

Posts posted by peter2005


  1. After reading all the responses I realized there is no easy way....

     

    My description is correct , it's a null-terminated ASCII string(one character one byte, no special ones), its length is not stored anywhere. Using static array only fixes problem of missing a first byte....

     

    What I wanted to avoid the most is reading the string byte by byte until #0 is found. 

     

    Quote

    To put it into a more manageable format, you could use your initial record - but you would have to read it element by element to stuff that record or object structure.

    I'll try this way.

     

    Quote

    A well designed stream would have had the string length as an int before the string.

    Perhaps but the file I want to read was created in Visual Studio ..so I presume in C++ are "normal" ways to read #0 strings.


  2. How can I read content of (typed) file of different data types when one of them is null-terminated string?


    Something like this:

     

     THeader = Record
        flags : integer;
        dummy  : integer;
        name: string;
        padding: integer;
      end;

     

    This would work fine if it were not for string field.

     

    By definition a record has to be of fixed size but generally strings are not.
    Another problem with string is the first byte is omitted since it is considered to be length.


    Most likely Record cannot be used for my purpose...is there anything else?
     


  3. 21 hours ago, Anders Melander said:

    To use alpha transparency you need to set Transparent=False.

    Here's what it looks like (Delphi 10.3):

    image.png.43f9d3c19e1548f3e3c61870192d2447.png

    Yes, it works, thanks.

     

    Unfortunately Tbitmap in D7 does not have AlphaFormat property.

     

     

     


  4. Here is small bmp image. There is a transparent background and greyishblack shadow at the bottom.

    The background is not the problem Image1.Transpartent=False removes it, but the shadow is always fully black.

     

    Can it be loaded and displayed properly?

    1.bmp


  5. Quote

    Because Windows doesn't have good support for 32bit alpha-channeled bitmaps to begin with.

    Lazarus(free pascal) can handle these bitmaps without any trouble.

     

    Quote

    Why don't you want to use a third party component? 

    I try to avoid installing third party component because it complicates transferring my projects , it has to be installed, even worse when it's for a simple thing like displaying bitmap. Do you have any suggestion of component which could work in my case?

     

    Quote

    What complications does PNG present to you?  Are you working with VCL or FMX?  The VCL's TPNGImage class is easy to use.  FMX's TBitmap can be a bit difficult, depending on what you are trying to do with it.  It would really help if you would explain the problem you are having exactly.

    Probably should not even mention that I use Delphi 7:classic_rolleyes: 

    TBitmap allows access to individual pixels which I need to rearrange, no idea if TPNGImage can do that.

     


  6. hi,

     

    for unclear reason delphi does not completely support 32 bit bitmaps. I'm trying to display a 32bit picture data(with alpha channel) in a TImage using TBitmap and have not found a proper way, some parts of the picture are just black. Interesting is that the image although not properly displayed can be saved into a file(image1.Picture.Bitmap.SaveToFile) and works perfectly fine in a picture viewer.

     

    Alternative is to use PNG which uses alpha channel however it complicates whole situation since TBitmap is easy to use.

     

    I do not want use 3rd-part components or huge libraries  ....a code code snippet or an unit to include would be great.

×