Author Topic: GdipLoadImageFromFile example  (Read 1286 times)

TouEnMasm

  • Member
  • *****
  • Posts: 1615
    • EditMasm
Re: GdipLoadImageFromFile example
« Reply #30 on: February 23, 2021, 03:23:41 AM »

find a tga dumper who can be of great help (enum...)
Quote
TGA ---------------------------------------------- XING_T32.TGA --------------------------
ColorMap Type = 0
ImageType = 2   TGA_TRUECOLOR
ColorMap First = 0
ColorMap Length = 0
ColorMap Entry Size = 0
Origin 0, 0
Size: 240 by 164
Bits Per Pixel 32
Image descriptor 20
        TGA_FLAGS_INVERTY
Fa is a musical note to play with CL

TouEnMasm

  • Member
  • *****
  • Posts: 1615
    • EditMasm
Re: GdipLoadImageFromFile example
« Reply #31 on: February 24, 2021, 08:32:58 PM »
reusing the dumpfile and the image given by LiaoMi (XING_T32.TGA) in C++.
Follow use of the Directx::ScratchImage class
Quote
int __cdecl wmain(int argc, wchar_t* argv[], wchar_t* envp[])
{
    const DirectX::Image* ImageStruct = 0 //  To show the content of Image struct

auto image = std::make_unique<ScratchImage>();
HRESULT hr = LoadFromTGAFile( L"XING_T32.TGA",nullptr, *image );
if ( FAILED(hr) )
    printf("LoadFromTGAFile failed");
else printf("LoadFromTGAFile REUSSITE \n");
//        size_t __cdecl GetPixelsSize() const { return m_size; }

ImageStruct = image->GetImages();
// image->m_image
printf("image width %d", ImageStruct->width );

Next step is to create a masm proto to call that.

Fa is a musical note to play with CL

Gunther

  • Member
  • *****
  • Posts: 3720
  • Forgive your enemies, but never forget their names
Re: GdipLoadImageFromFile example
« Reply #32 on: February 25, 2021, 04:02:37 AM »
Yves,

thank you for your efforts.

find a tga dumper who can be of great help (enum...)

The TGA header contains 18 bytes in which all information about the image and its display is stored. Reading these out and interpreting them correctly is really not witchcraft.
What MS has written in code for this simple task is very cumbersome. On the PowerBASIC page, you can find a TGA Viewer, written by me with PB 3.5 (DOS compiler).
The program can display True Color images and TGA images with DAC (256 colors) correctly. To be able to display large images, I used the XMS memory and worked with
VESA bank switching. The credits of the program still show my old mail address at CompuServe. So the program was written in the mid 90s.

Of course, my program has weaknesses. I am in the process of changing that. At that time VESA 2.0 was up to date and my program hard coded e.g. some VESA modes. 
The right thing to do, of course, is to get the list of available VESA modes and scan them etc.

Gunther   
Get your facts first, and then you can distort them.

TouEnMasm

  • Member
  • *****
  • Posts: 1615
    • EditMasm
Re: GdipLoadImageFromFile example
« Reply #33 on: February 25, 2021, 04:13:55 AM »

I have just a little problem with the upper function.
I can do manything to get informations and modify the file but ... I don't know how to view it ??
any idea ??
There is no DC given.
Fa is a musical note to play with CL

Gunther

  • Member
  • *****
  • Posts: 3720
  • Forgive your enemies, but never forget their names
Re: GdipLoadImageFromFile example
« Reply #34 on: February 25, 2021, 05:28:47 AM »
Yves,

I have just a little problem with the upper function.
I can do manything to get informations and modify the file but ... I don't know how to view it ??
any idea ??
There is no DC given.

not at the moment. Let me think about that.

Gunther
Get your facts first, and then you can distort them.