[Win32API] Load TGA Image?

is it possible? no conversions, normally load TGA image just like bitmap, I searched on google but found nothing except GDI+ but there's nothing about TGA
Google result #1 when searching for "C++ load targa": http://steinsoft.net/index.php?site=Programming/Code%20Snippets/Cpp/no8

Looks like basic code to load the TGA. It is C, though, not C++.
Last edited on
thanks, gonna try it, and from what I see the code looks just like any of mine O_o
well, how do I display it? do I need to create custom control since picture control is supporting only bitmap, icon and arrow or something like that
I wouldn't know. I imagine the actual raw color data needs translation to a bitmap, but I have never worked heavily with graphics. Best if you just look up a graphics library that is already-made and ready to go. I think Google result #7 or so was a C library for targa.
I've found one by angelcode for saving/loading TGA, but I can't find any function to display it :/ only some functions for conversion, gonna try it
This is how I loaded and displayed a tga file using CImg:

1
2
3
4
5
6
7
8
9
10
11
#include "CImg.h"
#include <iostream>
using namespace cimg_library;

int main()
{
  CImg<float> image("01.tga");
  CImgDisplay main_disp(image);
 
  std::cin.ignore();
}


Converting it to some other format would be simple enough.
can u give me some example on how to display it in window using picture control? just like bitmap

1
2
3
4
5
6
7
//.rc
    CONTROL         "", IDC_HEROIMAGE, WC_STATIC, SS_BITMAP, 210, 31, 20, 20

//.cpp

HANDLE hBitmap = LoadImage(g_hInst, MAKEINTRESOURCE(IDB_DEFAULT), IMAGE_BITMAP, 64, 64, NULL);
			SendMessage(GetDlgItem(hWnd, IDC_HEROIMAGE), STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
This is a very small library that can load .tga images and gives you a HBITMAP handle (this is what you need). It consists of only 2 files which you add to your project:

http://www.dhpoware.com/source/bitmap.html
It uses GDI+ internally.
Topic archived. No new replies allowed.