Drawing maps (.blp images) ? menu

Shout-Out

User Tag List

Results 1 to 3 of 3
  1. #1
    eLaps's Avatar Active Member
    Reputation
    34
    Join Date
    Sep 2007
    Posts
    123
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drawing maps (.blp images) ?

    Hi,
    I'm want to draw map files (with blp files found in MPQs) in a out-of-process gui and I know some of you already did it, so asking you may save me a lot of time.
    I would want to know if you just made it from scratch or if there is a trick to avoid all the boring (and hard if DXT encoding) work, maybe an external lib?

    Drawing maps (.blp images) ?
  2. #2
    namreeb's Avatar Legendary

    Reputation
    668
    Join Date
    Sep 2008
    Posts
    1,029
    Thanks G/R
    8/222
    Trade Feedback
    0 (0%)
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Should be pretty straight forward.

    BLP format: BLP - WoW.Dev Wiki

    DXT (de)compression lib: libsquish - Project Hosting on Google Code

    It may be easier to convert them to a standard format using something like this:

    http://www.mmowned.com/forums/simple...converter.html

  3. #3
    eLaps's Avatar Active Member
    Reputation
    34
    Join Date
    Sep 2007
    Posts
    123
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.
    I was trying to avoid any pre-conversion (making the conversion at execution in the RAM) but surprisingly I didn't find any RGBA8888 to PNG conversion lightweight library (ImageMagick does that but is over-complicated).
    But whatever, making preconverted copies is ok.

    edit:
    Finally, with Magick++:
    Code:
    #include <stdint.h>
    #include <fstream>
    #include <iostream>
    
    #include <Magick++.h>
    #include "squish.h"
    
    bool BLP2_Convert(const std::string& _blpfile, const std::string& _extension) {
    
        struct {
            char        BLP2[4];
            uint32_t    version;
            uint8_t        compression;
            uint8_t        alpha_depth;
            uint8_t        alpha_encoding;
            uint8_t        mipmaps;
            uint32_t    width;
            uint32_t    height;
            uint32_t     mipmaps_offsets[16];
            uint32_t     mipmaps_sizes[16];
        } blpheader;
    
        std::ifstream ifs(_blpfile.c_str(), std::ifstream::in|std::ifstream::binary);
    
            //Get header informations
        ifs.read((char*)&blpheader, 0x94);
        if (*(uint32_t*)&blpheader.BLP2[0] != 844123202) {
            std::cout << "Not BLP2\n";
            return false;
        }
    
            //Copy first mipmap
        squish::u8* blpimage = new squish::u8[blpheader.mipmaps_sizes[0]];
        ifs.seekg(blpheader.mipmaps_offsets[0], std::ios::beg);
        ifs.read((char*)blpimage, blpheader.mipmaps_sizes[0]);
        ifs.close();
    
            //Decompress it
        squish::u8* uncompressed;
        if (blpheader.compression == 2) {
            int dxtver;
            switch (blpheader.alpha_encoding) {
                case 0: dxtver = squish::kDxt1; break;
                case 1: dxtver = squish::kDxt3; break;
                case 7: dxtver = squish::kDxt5; break;
                default: std::cout << "DXT version not recognized.\n"; return false; break;
            }
            uncompressed = new squish::u8[blpheader.width * blpheader.height * 4];
            squish::DecompressImage(uncompressed, blpheader.width, blpheader.height, blpimage, dxtver);
        } else
            uncompressed = blpimage;
    
            //Convert and save it
        Magick::Blob blob(uncompressed, blpheader.width * blpheader.height * 4);
        Magick::Image converted;
        converted.size("256x256");
        converted.magick("RGBA");
        converted.depth(8);
        converted.read(blob);
        converted.write(_blpfile.substr(0, _blpfile.find_last_of('.')+1)+_extension);
    
        delete[] blpimage;
        if (blpheader.compression == 2)
            delete[] uncompressed;
    }
    
    int main() {
        BLP2_Convert("AzjolNerub3_2.blp", "jpg");
        BLP2_Convert("AzjolNerub3_2.blp", "png");
        return 0;
    }
    Last edited by eLaps; 04-11-2010 at 01:29 PM.

Similar Threads

  1. [Patch] Map Importing Finalization of World\Tex .blp files - Need help Xel :D
    By Zolascius1 in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 10-10-2010, 03:55 PM
  2. [HALP!] BLP<-->Editable Image Problem (Lines of DEATH)
    By garrawr in forum WoW ME Questions and Requests
    Replies: 6
    Last Post: 11-10-2009, 08:44 PM
  3. [Showoff] Isle of Conquest Map + Images!
    By Xel in forum World of Warcraft Exploration
    Replies: 7
    Last Post: 06-28-2009, 11:13 AM
  4. [BLP Edit] New Stormwind Map
    By kody_ in forum World of Warcraft Model Editing
    Replies: 3
    Last Post: 08-17-2008, 02:24 PM
  5. Wow Image Converter Script Messes Up BLPs
    By [email protected] in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 05-10-2008, 01:24 PM
All times are GMT -5. The time now is 01:56 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search