Announcement

Collapse
No announcement yet.

Texture load from file problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Texture load from file problem

    What's the correct format for texture load.These code doesn't work for me.
    Code:
    Texture := TextureInit(FDevice, 'c:/MyPic.bmp', TPixelFormat.RGBA8);
    Texture := TextureInit(FDevice,  ExtractFilePath(ParamStr(0)) + 'MyPic.bmp', TPixelFormat.RGBA8);
    and how about the Texture.SaveToFile() 's AQuality ?
    Texture.SaveToFile(' ', ??, 0, ZeroIntRect);

  • #2
    The code should be working, please check if the path is correct and "FDevice" is properly initialized. Also, check if Texture is initialized after loading. Afterwarp on Windows uses WIC for loading different image formats, BMP format is one of them: Native WIC Codecs. On Linux/FreeBSD, Afterwarp uses GTK.

    That "Quality" parameter is mainly used to define quality for JPEG files, so it should have values in range of 0 to 100; for other formats, it is ignored.
    If you still have problems with that file, could you either attach it here or send it to me via PM? Thanks.

    Comment


    • #3

      1. I just test the ImageBasics example. Otherwise,nothing change.But still get error message- 'Could not create model texture';
      Delphi 10.3, OS:Win7
      Code:
       // FTexture := TextureInit(FDevice, '../../../../media/kodim23.png', TPixelFormat.RGBA8);
        FTexture := TextureInit(FDevice, 'c:/MyPic.bmp', TPixelFormat.RGBA8);
        if not FTexture.Initialized then
        begin
          MessageDlg('Could not create model texture.', mtError, [mbOK], 0);
          Application.Terminate;
          Exit;
        end;

      2. Please give a sample code for Texture.SaveToFile ,that donsn't works for me.
      Last edited by DraculaLin; 01-25-2020, 12:13 AM.

      Comment


      • #4
        Originally posted by DraculaLin View Post
        1. I just test the ImageBasics example. Otherwise,nothing change.But still get error message- 'Could not create model texture';
        Delphi 10.3, OS:Win7
        Code:
        // FTexture := TextureInit(FDevice, '../../../../media/kodim23.png', TPixelFormat.RGBA8);
        FTexture := TextureInit(FDevice, 'c:/MyPic.bmp', TPixelFormat.RGBA8);
        if not FTexture.Initialized then
        begin
        MessageDlg('Could not create model texture.', mtError, [mbOK], 0);
        Application.Terminate;
        Exit;
        end;
        Does ImageBasics example work with "kodim23.png" image? Can you try running ImageBasics pre-compiled example from "Samples" folder of C++ samples? If the last one works, then can you please send me the image that you are having problems with?

        2. Please give a sample code for Texture.SaveToFile ,that donsn't works for me.
        In ImageBasics example, just after "FTexture := TextureInit", you can try this (should work):
        Code:
          FTexture := TextureInit(FDevice, 'kodim23.png', TPixelFormat.RGBA8);
          if not FTexture.Initialized then
          begin
            MessageDlg('Could not create model texture.', mtError, [mbOK], 0);
            Application.Terminate;
            Exit;
          end;
        
          // Save texture to another file.
          FTexture.SaveToFile('test.png', nil, 0, ZeroIntRect);

        Comment


        • #5
          1. kodim23.png doesn' work, every C++ samples works fine except 'ImageBasics' and 'CubeTextured'(error message)

          2. FTexture.SaveToFile('test.png', nil, 0, ZeroIntRect) -->can't test since can't load image...
          Test with DrawableTexture example,the image is empty(0k)

          Comment


          • #6
            Originally posted by DraculaLin View Post
            Delphi 10.3, OS:Win7
            Can you please clarify exact version of your OS? (e.g. through "winver" application or "ver" in command prompt)
            Is it a vanilla Windows 7 installation or a customized one with something like RT Se7en Lite?

            I cannot reproduce this in either Windows 7 fresh installation or fully patched. However, a year ago I got a report from one person with a customized Windows 7 installation that also was getting WIC errors.

            Comment


            • #7
              It's Windows 7 Ultimate,not customized or RT,se,lite...etc.

              If it caused by WIC why these Delphi code work fine ? or Delphi's WIC different from native WIC Codecs ?
              http://docwiki.embarcadero.com/Libra...hics.TWICImage
              Code:
              procedure TForm1.Button1Click(Sender: TObject);
              var
                WIC: TWICImage;
              begin
                 WIC := TWICImage.Create;
                try
                  WIC.LoadFromFile('C:/MyPic.bmp');
                  Image1.Picture.Assign(WIC);
                finally
                  WIC.Free;
                end;
              end;

              Comment


              • #8
                I can't say much about Delphi's WIC, as Afterwarp doesn't use it (it is written in C++ with certain portions in C). In Afterwarp, WIC is initialized as:
                Code:
                  CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory,
                    reinterpret_cast<LPVOID*>(_factory->imagingFactory.GetAddressOf()));
                In PXL/Asphyre, it was initialized as:
                Code:
                  CoCreateInstance(CLSID_WICImagingFactory, nil, CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER, IUnknown,
                    FImagingFactory);
                The only difference I can see is "CLSCTX_LOCAL_SERVER" parameter. I have attached Afterwarp v1.1.x DLL compiled with this additional option, could you please copy it to the samples folder and try if it makes any difference?

                Comment


                • #9
                  Still the same error

                  Comment


                  • #10
                    As per my previous request:
                    Can you please clarify exact version of your OS? (e.g. through "winver" application or "ver" in command prompt)
                    I would like to know exact build version, SP pack version, etc. A screenshot from winver tool would be nice.

                    Comment


                    • #11
                      strange ?
                      Just try PXL,the Basic sample works fine for me
                      Last edited by DraculaLin; 01-25-2020, 09:48 PM.

                      Comment


                      • #12
                        Thanks. I couldn't reproduce the issue on any of my Windows 7 virtual machines, but could reproduce in Windows Vista x64 SP2, so I'm investigating and once fixed, will issue an update.

                        Comment


                        • #13
                          Can you please copy the attached Afterwarp DLL and try again?

                          Comment


                          • #14
                            This works perfect

                            Comment


                            • #15
                              Thank you for reporting and testing this problem. The issue was that Afterwarp was trying to use GUID_WICPixelFormat32bppRGB and GUID_WICPixelFormat64bppPRGBAHalf formats from WIC (corresponding to TPixelFormat.RGBX8 and TPixelFormat.RGBA16F respectively), but those require either Windows 8 or Windows 7 with Platform Update. Most likely on your configuration you didn't install Platform Update (which is recommended as it brings new features for Direct3D, WIC, etc.), so the format manager would fail to initialize.

                              In either case, in Afterwarp for Windows 32-bit and 64-bit (but not ARM64), I've disabled those two formats in WIC to enable better compatibility with Windows Vista and Windows 7. These formats are not critical, since there are alternatives such as GUID_WICPixelFormat32bppRGBA (TPixelFormat.RGBA8) and GUID_WICPixelFormat64bppRGBAHalf (TPixelFormat.RGBA16F without premultiplied alpha).

                              I'll post an update to Afterwarp soon, along with an additional example.

                              Comment

                              Working...
                              X