[Include] beta iImage
#1

Fiz essa include agora pela madrugada, й mais uma parte integrante da IPSI!


Basicamente essa include carrega as informaзхes de imagens no formato BIT MAP (.bmp) em pawn. Podendo fazer usar em informaзхes gerais ou atй imprimir logos na tela de seus usuбrios usando Text Draw



Cуdigo


pawn Код:
/*
 *
 * iImage 1.1
 * Criado por Bruno da Silva
 * Include pertencente a IPSI
 * Agradecimentos ipsTeam e William Luigi por iBits
 *
*/



#define GetSizeX(%0)            %0[bitWidth]
#define GetSizeY(%0)            %0[bitHeigth]




enum bitmapType {

    bitType,
    bitSize,
    bitReserve1,
    bitReserve2,
    bitOffset,
    bitLen,
    bitWidth,
    bitHeigth,
    bitDados,
    bitCount,
    bitCompacto,
    bitImgSize,
    bitX,
    bitY,
    usadoCl,
    usadoClImp


};

stock GetPixelColor(File: imageFileex, xx, yy, arr[]) {

    new seek = 52;


    new n = (GetSizeY(arr) - yy ) * (GetSizeX(arr) % 4);
    new o = (GetSizeY(arr) - yy - 1 ) * GetSizeX(arr) ;
    new o_ = yy - (yy - xx) ;
    new b = 3;

    seek +=  (n + ((o + o_) * b));

    fseek( imageFileex, seek);

    static REX,GEX,BEX;

    BEX = fgetchar(imageFileex, 0, false);
    GEX = fgetchar(imageFileex, 0, false);
    REX = fgetchar(imageFileex, 0, false);


    return (REX<<24|GEX<<16|BEX<<8|0xFf);
}

stock File: OpenImage(img[], arr[]) {

    static File: imageFile ;

    if((imageFile = fopen(img, io_read))) {


        static bin[4];

        arr[bitmapType] = (fgetchar(imageFile, 0, false) | (fgetchar(imageFile, 0, false) << 8));


        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[bitSize] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];


        arr[bitReserve1] = fgetchar(imageFile, 0, false) | (fgetchar(imageFile, 0, false) << 8);
        arr[bitReserve2] = fgetchar(imageFile, 0, false) | (fgetchar(imageFile, 0, false) << 8);


        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[bitOffset] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];

        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[bitLen] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];


        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[bitWidth] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];

        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[bitHeigth] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];


        arr[bitDados] = fgetchar(imageFile, 0, false) | (fgetchar(imageFile, 0, false) << 8);
        arr[bitCount] = fgetchar(imageFile, 0, false) | (fgetchar(imageFile, 0, false) << 8);

        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[bitCompacto] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];

        arr[bitImgSize] = (fgetchar(imageFile, 0, false) | (fgetchar(imageFile, 0, false) << 8));


        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[bitX] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];

        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[bitY] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];



        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[usadoCl] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];


        bin[0] = fgetchar(imageFile, 0, false);
        bin[1] = fgetchar(imageFile, 0, false);
        bin[2] = fgetchar(imageFile, 0, false);
        bin[3] = fgetchar(imageFile, 0, false);

        arr[usadoClImp] =  (bin[3] << 24) | (bin[2] << 16) | (bin[1] << 8) | bin[0];

        return imageFile;
    }

    return File: false;
}

stock CloseImage(File: img) {
    return fclose(img);
}





Funзхes:


GetSizeX(array)

Pega o tamanho da imagem em largura






GetSizeY(array)


Pega o tamanho da imagem em altura






GetPixelColor(imagefile, pixelx, pixely, arrayheader)

Pega cor de um pixel dado




OpenImage("arquivo", arrayparaguardarinformacoes, arrayparaguardarpixels)


Essa funзгo й importante, pois serve para ler a imagem e armazenar os dados dela e um arquivo!


arrayparaguardarinformacoes vai guardar os dados como nъmero de blocos, qualidade da imagem, tamanho da imagem na vertical e na horizontal, etc.



E por fim! Meninas, nгo coloquem em seu servidor muitos coraзхeszinhos e meninos, nгo coloquem em seu servidor muitas caveirinhas. Fica feio
Reply


Messages In This Thread
beta iImage 1.1 - by ipsBruno - 29.10.2013, 09:55
Respuesta: beta iImage - by ipsBruno - 29.10.2013, 10:01
Respuesta: beta iImage - by DanDRT - 29.10.2013, 10:47
Re: beta iImage - by Menor - 29.10.2013, 12:12
Re: beta iImage - by PT - 29.10.2013, 13:56
Re: beta iImage - by Schocc - 29.10.2013, 14:03
Re: beta iImage - by smiiir - 29.10.2013, 14:28
Re: beta iImage - by N3XTMapper - 29.10.2013, 15:37
Re: beta iImage - by WLSF - 29.10.2013, 17:55
Re: beta iImage - by Juniiro3 - 29.10.2013, 17:59

Forum Jump:


Users browsing this thread: 1 Guest(s)