Exemplo n.º 1
0
GraphicComp* ImportCmd::Import (const char* filename) {
    GraphicComp* comp = nil;
    const char* creator = ReadCreator(filename);

    if (creator == nil || strcmp(creator, "idraw") == 0) {
        Catalog* catalog = unidraw->GetCatalog();

        if (catalog->Valid(filename, (Component*&) comp)) {
            comp = (GraphicComp*) comp->Copy();

        } else if (catalog->Retrieve(filename, (Component*&) comp)) {
            catalog->Forget(comp);
        }

    } else {
        if (strcmp(creator, "X11") == 0) {
            comp = XBitmap_Image(filename);

        } else if (strcmp(creator, "TIFF") == 0) {
            comp = TIFF_Image(filename);

        } else if (
	    strcmp(creator, "pgmtops") == 0 ||
	    strcmp(creator, "pnmtops") == 0
	) {
            comp = PGM_Image(filename);

        } else if (strcmp(creator, "ppmtops") == 0) {
            comp = PPM_Image(filename);
        }
    }
    return comp;
}