Freelancer: rfedyk
Jaa:
Tee ilmoitus työstä

Questions need answering

There is critical information missing that can only be filled with assumptions CL_SpriteDescription is a class and you have given no definiion of the class. Similarly no defintion is give for CL_PixelBuffer I have done plenty of graohics programmimg and I know exactly what this procedure is doing but I am still only guessing at things and that could be a waste of time. If you want a generic procedure then CL_SpriteDescription is dropped. cl_rgba is an undefined constant but obviously stands for an R G B & alpha channel where each value is a byte and the 4 byte array represents 1 pixel. explored_vector is a byte array where each byte represents 1 pixel and where each byte is set to 1 if we have touched it. The rest of the conversion is dead simple. Regards Roger Fedyk

Kilpailutyö #4 kilpailussa                                                 C++ to Delphi traslation help

Julkinen selvennystaulu

  • rfedyk
    rfedyk
    • 10 vuotta sitten

    Hi

    I need to do this in three messages because of Freelancer limitations.

    Ok the coding is finished except that I may change it slightly depending on what you think about the following.

    You mentioned using Scanline or Pixel. Pixel is far too slow.

    However I wanted to make sure that I did not disturb the existing C++ logic so I wanted to use the Delphi equivalent of the C++ 'data' variable.

    Immediately a problem surfaces in that the easiest way to get to the buffer holding the picture data would be to point to the address of Scanline[0].
    However Delphi does not guarantee that the pixel data is contiguous in memory which is why they use Scanline and Pixel.
    In the C++ environment Microsoft create an in-memory DIB which gives you immediate access to the whole pixel buffer.

    • 10 vuotta sitten
    1. Tlaloc
      Kilpailun järjestäjä
      • 10 vuotta sitten

      My idea of using scanline[x] and scanline[y] was that it could be easily to discriminate those pixels with Alpha channel in a PNG image but it probably be much faster using the original approach of the in memory DIB.

      I don't think I will need a multi-thread processing, I understand that is lot more work.

      • 10 vuotta sitten
  • rfedyk
    rfedyk
    • 10 vuotta sitten

    Passing back a TList of TRect means that multi-threading is ignored which also affects the final speed of execution when using this procedure.
    I mention this last point only for information as implementing a callback is another lot of coding to be done.

    Once I get you your comments I'll do whatever updates might be needed and send you the unit.

    Of course you would need to award me the contest first or whatever is the process on Freelancer.

    Regards
    Roger

    • 10 vuotta sitten
  • rfedyk
    rfedyk
    • 10 vuotta sitten

    To utilize the C++ logic I have created an integer buffer called 'data' and read in each scanline's worth of pixel data and then moved it to the buffer that I have created.
    This does create a small amount of overhead but it has meant that I have used the C++ code without any change except the syntax.

    Another issue that arises is the true value of the Alpha channel byte.
    The existing C++ procedure forces any incoming image to be RGBA irrespective of what its original pixel format is.
    In this case if it has been coerced from 16 or 24 bit format then the Alpha channel value will always be zero which indicates full transparency.

    Finally, the callback code using 'impl' would appear to be designed to allow multi-thread processing of the image.

    • 10 vuotta sitten
  • rfedyk
    rfedyk
    • 10 vuotta sitten

    Hi Tllaloc

    Well, you obviously know what you are doing as well.

    I'm in the middle of a writing project and have to get in another 12,000 words worth by Wednesday.

    I'd like to do a version of this but I won't be able to start until Thursday.

    If that's to late I understand.

    Got my creative juices flowing though. Very interesting.

    Regards
    Roger Fedyk

    • 10 vuotta sitten
    1. Tlaloc
      Kilpailun järjestäjä
      • 10 vuotta sitten

      I can wait until the weekend no problem

      • 10 vuotta sitten
  • rfedyk
    rfedyk
    • 10 vuotta sitten

    Hi Tlaloc

    Ok, I have looked at the class description.

    As far as having a Delphi procedure that duplicates the C++ class method that is a very straightforward line-by-line conversion.

    Probably an hour's work.

    However I missed something in your cpprouting.txt file.

    The very last line

    impl->frames.push_back(CL_SpriteDescriptionFrame(pixelbuffer, CL_Rect(x1, y1, x2, y2)));

    is a callback function where "impl" is probably a socket which handles another structure "frames".

    The whole project opens up a can of worms where you end up converting hundreds if not thousands of lines of code.

    I presume that you are interested in gaming. There should be relatively inexpensive libraries, maybe even free, that do all this.

    But I would guess not in Delphi, but I could be wrong.

    Regards
    Roger Fedyk

    • 10 vuotta sitten
    1. Tlaloc
      Kilpailun järjestäjä
      • 10 vuotta sitten

      I would like to translate the method and have a small demo of how it works. In the C# version you can see the CL_SpriteDescriptionFrame class is replaced with a TList class of Rect, wich means that this methods just creates a list of rectangle coordinates.

      The declaration of the method in C# looks like this:
      private static List FindFrameRects(Texture tex,int scanStartX, int scanStartY, double transparencyLimit)

      In C++

      void CL_SpriteDescription::add_alphaclipped_frames_free( const CL_Texture &texture, int xpos, int ypos, double trans_limit)

      The CL_SpriteDescription might be replaced with a TList or TStringList Class
      and CL_Texture could be replaced with TBitmap.

      • 10 vuotta sitten
  • Tlaloc
    Kilpailun järjestäjä
    • 10 vuotta sitten

    Hi Robert I did upload the whole file containing the class CL_SpriteDescription, I think you really know what you are doing. Tell me what you think.

    Thanks.

    • 10 vuotta sitten

Näytä lisää kommentteja Käsitellään...