commit
eb05c962de
@ -0,0 +1,124 @@
|
||||
|
||||
gc()
|
||||
nodes = getCurrentSelection()
|
||||
max select none
|
||||
clearselection()
|
||||
|
||||
undo off
|
||||
(
|
||||
for cnode in nodes do
|
||||
(
|
||||
if (classof cnode) == Editable_Patch or (classof cnode) == RklPatch then
|
||||
(
|
||||
print cnode.name
|
||||
selectmore cnode
|
||||
if (classof cnode) == Editable_Patch and (classof cnode) != RklPatch then
|
||||
(
|
||||
modPanel.addModToSelection (NeL_Convert ()) ui:on
|
||||
)
|
||||
modPanel.addModToSelection (NeL_Edit ()) ui:on
|
||||
setCommandPanelTaskMode #modify
|
||||
cmod = modpanel.getCurrentObject()
|
||||
pcount = (GetRykolPatchCount cnode)
|
||||
print pcount
|
||||
for p = 1 to pcount do
|
||||
(
|
||||
--print p
|
||||
vbegin = (NeLGetPatchVertex cnode p 1)
|
||||
vend = (NeLGetPatchVertex cnode p 2)
|
||||
vref = (NeLGetPatchVertex cnode p 3)
|
||||
begin = (GetRykolVertexPos cnode vbegin)
|
||||
end = (GetRykolVertexPos cnode vend)
|
||||
ref = (GetRykolVertexPos cnode vref)
|
||||
normal = (cross (end - begin) (ref - begin))
|
||||
normal = (normalize normal)
|
||||
|
||||
rotnormal = (point3 0 0 0)
|
||||
if (normal.z > 0.9) then
|
||||
(
|
||||
--print "x normal"
|
||||
rotnormal = (normal * (rotateXMatrix -90))
|
||||
)
|
||||
else
|
||||
(
|
||||
normal.z = 0
|
||||
normal = (normalize normal)
|
||||
rotnormal = (normal * (rotateZMatrix -90))
|
||||
)
|
||||
--print rotnormal
|
||||
|
||||
-- print normal
|
||||
-- print rotnormal
|
||||
-- print begin
|
||||
-- print end
|
||||
dir = (normalize (end - begin))
|
||||
-- print dir
|
||||
score1 = (dot dir rotnormal)
|
||||
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
vbegin = (NeLGetPatchVertex cnode p 1)
|
||||
vend = (NeLGetPatchVertex cnode p 2)
|
||||
begin = (GetRykolVertexPos cnode vbegin)
|
||||
end = (GetRykolVertexPos cnode vend)
|
||||
dir = (normalize (end - begin))
|
||||
score2 = (dot dir rotnormal)
|
||||
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
vbegin = (NeLGetPatchVertex cnode p 1)
|
||||
vend = (NeLGetPatchVertex cnode p 2)
|
||||
begin = (GetRykolVertexPos cnode vbegin)
|
||||
end = (GetRykolVertexPos cnode vend)
|
||||
dir = (normalize (end - begin))
|
||||
score3 = (dot dir rotnormal)
|
||||
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
vbegin = (NeLGetPatchVertex cnode p 1)
|
||||
vend = (NeLGetPatchVertex cnode p 2)
|
||||
begin = (GetRykolVertexPos cnode vbegin)
|
||||
end = (GetRykolVertexPos cnode vend)
|
||||
dir = (normalize (end - begin))
|
||||
score4 = (dot dir rotnormal)
|
||||
|
||||
-- print score1
|
||||
-- print score2
|
||||
-- print score3
|
||||
-- print score4
|
||||
|
||||
if (score1 > score2 and score1 > score3 and score1 > score4) then
|
||||
(
|
||||
-- print "score 1"
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
)
|
||||
else if (score2 > score3 and score2 > score4) then
|
||||
(
|
||||
-- print "score 2"
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
)
|
||||
else if (score3 > score4) then
|
||||
(
|
||||
-- print "score 3"
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
)
|
||||
else
|
||||
(
|
||||
-- print "score 4"
|
||||
)
|
||||
)
|
||||
maxOps.CollapseNode cnode off
|
||||
max select none
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
max select none
|
||||
clearselection()
|
||||
undo off
|
||||
(
|
||||
for cnode in nodes do
|
||||
(
|
||||
selectmore cnode
|
||||
)
|
||||
)
|
@ -0,0 +1,68 @@
|
||||
-- This script sets proper centered zone positions and generates their names
|
||||
-- Use after cutting the zone into 160m by 160m pieces
|
||||
|
||||
cell_size = 160.0
|
||||
offset_x = 7680 / 2
|
||||
offset_y = -(20480 + (5120 / 2))
|
||||
|
||||
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
-- http://proofofprogress.blogspot.be/2011/03/solution-align-pivot-to-world-without.html
|
||||
Function alignPivotToWorld &theObject = (
|
||||
--VLM = Visible Local Matrix.
|
||||
--The matrix/pivot you see when selecting object and "Local" axis is selected as viewable.
|
||||
VLM = theObject.Transform;
|
||||
IP_LocalRot = theObject.objectOffsetRot; --Rotation to be used later.
|
||||
IP_LOCAL = theObject.objectOffsetPos; --Invisible Pivot Local coordinates
|
||||
--In relation to VLM matrix.
|
||||
IP_WORLD = IP_LOCAL * VLM; --World Coordinates of Invisible Pivot. [Local To World Transform]
|
||||
VLM_0 = matrix3 1; --Reset Visible Local matrix coordinates.
|
||||
|
||||
NEW_IP_LOCAL = IP_WORLD * inverse(VLM_0); --[World To local Transform]
|
||||
|
||||
theObject.Transform = VLM_0;
|
||||
theObject.objectOffsetPos = NEW_IP_LOCAL;
|
||||
|
||||
--Now Handle Rotation:
|
||||
--Since rotation of visible local matrix has been zeroed out,
|
||||
--You must add that loss to the invisible pivot rotation.
|
||||
GeomWorldRot = VLM.RotationPart + IP_LocalRot;
|
||||
theObject.objectOffsetRot = GeomWorldRot;
|
||||
)
|
||||
|
||||
-- Convert a coordinate in a name
|
||||
-- name = coordToName #(x, y)
|
||||
fn coordToName coord =
|
||||
(
|
||||
up = floor(coord[1] / 26) + 1
|
||||
down = floor(coord[1] - ((up-1) * 26)) + 1
|
||||
return (((-coord[2] + 1) as integer) as string) + "_" + alphabet[up] + alphabet[down]
|
||||
)
|
||||
|
||||
fn realCoordToName coord =
|
||||
(
|
||||
return coordToName(#(((coord[1] + offset_x) / cell_size) + 0.5, ((coord[2] + offset_y) / cell_size) + 0.5))
|
||||
)
|
||||
|
||||
fn roundedCoord coord =
|
||||
(
|
||||
return #(ceil(coord[1] / cell_size) * cell_size - (cell_size / 2), ceil(coord[2] / cell_size) * cell_size - (cell_size / 2))
|
||||
)
|
||||
|
||||
max select none
|
||||
clearselection()
|
||||
|
||||
for node in geometry do
|
||||
(
|
||||
if (classof node) == RklPatch or (classof node) == Editable_Patch then
|
||||
(
|
||||
newcoords = roundedCoord(#(node.center.x, node.center.y))
|
||||
newname = realCoordToName(newcoords)
|
||||
node.name = newname
|
||||
alignPivotToWorld &node
|
||||
node.pivot.x = newcoords[1]
|
||||
node.pivot.y = newcoords[2]
|
||||
resetxform node
|
||||
maxOps.CollapseNode node off
|
||||
)
|
||||
)
|
@ -0,0 +1,162 @@
|
||||
-- Use to take the snapshots of a large manually created zone
|
||||
|
||||
from_x = 160
|
||||
size_x = 7680-320
|
||||
from_y = -25600+160
|
||||
size_y = 5120-320
|
||||
|
||||
targetdir = "W:/database/landscape/ligo/asteroids/max"
|
||||
snapshotdir = "W:/database/landscape/ligo/asteroids/zonebitmaps"
|
||||
zonename = "anne"
|
||||
resumeonly = true
|
||||
|
||||
cell_size = 160.0
|
||||
|
||||
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
fn lowercase instring = -- beginning of function definition
|
||||
(
|
||||
local upper, lower, outstring -- declare variables as local
|
||||
upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ" -- set variables to literals
|
||||
lower="abcdefghijklmnopqrstuvwxyz"
|
||||
outstring=copy instring
|
||||
for i=1 to outstring.count do
|
||||
(
|
||||
j=findString upper outstring[i]
|
||||
if (j != undefined) do outstring[i]=lower[j]
|
||||
)
|
||||
return outstring -- value of outstring will be returned as function result
|
||||
)
|
||||
|
||||
fn existFile fname = (getfiles fname).count != 0
|
||||
|
||||
-- Convert a coordinate in a name
|
||||
-- name = coordToName #(x, y)
|
||||
fn coordToName coord =
|
||||
(
|
||||
up = floor(coord[1] / 26) + 1
|
||||
down = floor(coord[1] - ((up-1) * 26)) + 1
|
||||
return (((-coord[2] + 1) as integer) as string) + "_" + alphabet[up] + alphabet[down]
|
||||
)
|
||||
|
||||
fn roundedCoord coord =
|
||||
(
|
||||
return #(ceil(coord[1] / cell_size) * cell_size - (cell_size / 2), ceil(coord[2] / cell_size) * cell_size - (cell_size / 2))
|
||||
)
|
||||
|
||||
fn coordId coord =
|
||||
(
|
||||
coordr = (roundedCoord coord)
|
||||
return #(((coordr[1]) / cell_size) + 0.5, ((coordr[2]) / cell_size) + 0.5)
|
||||
)
|
||||
|
||||
from_coord = (coordId #(from_x, from_y))
|
||||
to_coord = (coordId #(from_x + size_x, from_y + size_y))
|
||||
|
||||
print from_coord
|
||||
print to_coord
|
||||
|
||||
print (coordToName from_coord)
|
||||
|
||||
undo off
|
||||
(
|
||||
for x=from_coord[1] to to_coord[1] do
|
||||
(
|
||||
for y=from_coord[2] to to_coord[2] do
|
||||
(
|
||||
ny=y+1
|
||||
sy=y-1
|
||||
ex=x+1
|
||||
wx=x-1
|
||||
zc = coordToName #(x, y)
|
||||
zn = coordToName #(x, ny)
|
||||
zne = coordToName #(ex, ny)
|
||||
ze = coordToName #(ex, y)
|
||||
zse = coordToName #(ex, sy)
|
||||
zs = coordToName #(x, sy)
|
||||
zsw = coordToName #(wx, sy)
|
||||
zw = coordToName #(wx, y)
|
||||
znw = coordToName #(wx, ny)
|
||||
maxc = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zc) + ".max"
|
||||
csnapfile = snapshotdir + "/" + zonename + "-" + (lowercase zc) + ".tga"
|
||||
if existFile maxc and (not resumeonly or not (existFile csnapfile)) then
|
||||
(
|
||||
print zc
|
||||
resetMAXFile #noprompt
|
||||
gc()
|
||||
mergeMAXFile maxc #(zc)
|
||||
ccenter = getnodebyname zc
|
||||
maxn = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zn) + ".max"
|
||||
if existFile maxn then
|
||||
(
|
||||
mergeMAXFile maxn #(zn)
|
||||
cnode = getnodebyname zn
|
||||
cnode.position.y = cnode.position.y + 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxne = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zne) + ".max"
|
||||
if existFile maxne then
|
||||
(
|
||||
mergeMAXFile maxne #(zne)
|
||||
cnode = getnodebyname zne
|
||||
cnode.position.x = cnode.position.x + 160
|
||||
cnode.position.y = cnode.position.y + 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxe = targetdir + "/zonematerial-" + zonename + "-" + (lowercase ze) + ".max"
|
||||
if existFile maxe then
|
||||
(
|
||||
mergeMAXFile maxe #(ze)
|
||||
cnode = getnodebyname ze
|
||||
cnode.position.x = cnode.position.x + 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxse = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zse) + ".max"
|
||||
if existFile maxse then
|
||||
(
|
||||
mergeMAXFile maxse #(zse)
|
||||
cnode = getnodebyname zse
|
||||
cnode.position.x = cnode.position.x + 160
|
||||
cnode.position.y = cnode.position.y - 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxs = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zs) + ".max"
|
||||
if existFile maxs then
|
||||
(
|
||||
mergeMAXFile maxs #(zs)
|
||||
cnode = getnodebyname zs
|
||||
cnode.position.y = cnode.position.y - 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxsw = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zsw) + ".max"
|
||||
if existFile maxsw then
|
||||
(
|
||||
mergeMAXFile maxsw #(zsw)
|
||||
cnode = getnodebyname zsw
|
||||
cnode.position.x = cnode.position.x - 160
|
||||
cnode.position.y = cnode.position.y - 160
|
||||
--NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxw = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zw) + ".max"
|
||||
if existFile maxw then
|
||||
(
|
||||
mergeMAXFile maxw #(zw)
|
||||
cnode = getnodebyname zw
|
||||
cnode.position.x = cnode.position.x - 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxnw = targetdir + "/zonematerial-" + zonename + "-" + (lowercase znw) + ".max"
|
||||
if existFile maxnw then
|
||||
(
|
||||
mergeMAXFile maxnw #(znw)
|
||||
cnode = getnodebyname znw
|
||||
cnode.position.x = cnode.position.x - 160
|
||||
cnode.position.y = cnode.position.y + 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
NeLWeldPatchMesh ccenter 1.0
|
||||
NeLLigoMakeSnapShot ccenter csnapfile 0 1 0 1 false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -1,126 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define PIC_ERRSIZE 256
|
||||
|
||||
static unsigned long PIC_Sys_MEM_Allocated;
|
||||
static unsigned long PIC_Sys_MEM_NbAllocs;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void *Pic_malloc(unsigned long size)
|
||||
{
|
||||
void *mem;
|
||||
mem=malloc(size);
|
||||
if (mem)
|
||||
{
|
||||
PIC_Sys_MEM_Allocated+=size;
|
||||
PIC_Sys_MEM_NbAllocs++;
|
||||
}
|
||||
return(mem);
|
||||
}
|
||||
// -----
|
||||
void *Pic_calloc(unsigned long count, unsigned long size)
|
||||
{
|
||||
void *mem;
|
||||
mem=calloc(count,size);
|
||||
if (mem)
|
||||
{
|
||||
PIC_Sys_MEM_Allocated+=(size*count);
|
||||
PIC_Sys_MEM_NbAllocs++;
|
||||
}
|
||||
return(mem);
|
||||
}
|
||||
// -----
|
||||
void Pic_free(void *memblock)
|
||||
{
|
||||
unsigned long size;
|
||||
size=(unsigned long)_msize(memblock);
|
||||
PIC_Sys_MEM_Allocated-=size;
|
||||
PIC_Sys_MEM_NbAllocs--;
|
||||
free(memblock);
|
||||
}
|
||||
// -----
|
||||
unsigned long Pic__msize(void *memblock)
|
||||
{
|
||||
return(unsigned long)(_msize(memblock));
|
||||
}
|
||||
// -----
|
||||
unsigned long PIC_GetMemNbAllocs(void)
|
||||
{
|
||||
return(PIC_Sys_MEM_NbAllocs);
|
||||
}
|
||||
// -----
|
||||
unsigned long PIC_GetMemAllocated(void)
|
||||
{
|
||||
return(PIC_Sys_MEM_Allocated);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static char PIC_ErrorFlag;
|
||||
static char PIC_ErrorString[PIC_ERRSIZE];
|
||||
static unsigned char PIC_Sys_FnctActive=0;
|
||||
static void (*PIC_Sys_Fnct)(void);
|
||||
|
||||
void Pic_SetError(const char *msg, ...)
|
||||
{
|
||||
char curerr[PIC_ERRSIZE],olderr[PIC_ERRSIZE];
|
||||
va_list args;
|
||||
|
||||
va_start(args,msg);
|
||||
vsprintf(curerr,msg,args);
|
||||
va_end(args);
|
||||
if ( (strlen(curerr)+strlen(PIC_ErrorString))>PIC_ERRSIZE ) return;
|
||||
|
||||
if (PIC_ErrorFlag)
|
||||
{
|
||||
strcpy(olderr,PIC_ErrorString);
|
||||
sprintf(PIC_ErrorString,"--- [PIC#%03d] :\n%s",PIC_ErrorFlag,curerr);
|
||||
strcat(PIC_ErrorString,"\n");
|
||||
strcat(PIC_ErrorString,olderr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(PIC_ErrorString,"--- [PIC#%03d] :\n%s",PIC_ErrorFlag,curerr);
|
||||
}
|
||||
PIC_ErrorFlag++;
|
||||
if (PIC_Sys_FnctActive) PIC_Sys_Fnct();
|
||||
return;
|
||||
}
|
||||
// -----
|
||||
char* PIC_GetError(void)
|
||||
{
|
||||
return(PIC_ErrorString);
|
||||
}
|
||||
// -----
|
||||
unsigned char PIC_Error(void)
|
||||
{
|
||||
return(PIC_ErrorFlag);
|
||||
}
|
||||
// -----
|
||||
void PIC_ResetError(void)
|
||||
{
|
||||
strcpy(PIC_ErrorString,"");
|
||||
PIC_ErrorFlag=0;
|
||||
}
|
||||
// -----
|
||||
unsigned char PIC_OnErrorCall( void pFnct(void) )
|
||||
{
|
||||
if (pFnct != NULL)
|
||||
{
|
||||
PIC_Sys_Fnct=pFnct;
|
||||
PIC_Sys_FnctActive=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PIC_Sys_FnctActive=0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1,215 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pic_private.h"
|
||||
#include "pic.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct BMP_HEADER
|
||||
{
|
||||
unsigned short bfType;
|
||||
unsigned long bfSize;
|
||||
unsigned short Res1;
|
||||
unsigned short Res2;
|
||||
unsigned long bfOffBits;
|
||||
unsigned long biSize;
|
||||
unsigned long biWidth;
|
||||
unsigned long biHeight;
|
||||
unsigned short biPlanes;
|
||||
unsigned short biBitCount;
|
||||
unsigned long biCompression;
|
||||
unsigned long biSizeImage;
|
||||
unsigned long biXPelsPerMeter;
|
||||
unsigned long biYPelsPerMeter;
|
||||
unsigned long biClrUsed;
|
||||
unsigned long biClrImportant;
|
||||
} BMP_HEADER;
|
||||
#pragma pack()
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_BMP_Write( const char *FileName,
|
||||
char *pPal, char *pDatas,
|
||||
unsigned long w, unsigned long h, unsigned long d)
|
||||
|
||||
{
|
||||
FILE *file;
|
||||
BMP_HEADER bmph;
|
||||
unsigned long slsize;
|
||||
unsigned char *scanline;
|
||||
unsigned long i;
|
||||
long x,y,rest;
|
||||
unsigned char r,g,b;
|
||||
|
||||
file=fopen(FileName,"wb");
|
||||
if (!file)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
memset(&bmph,0,sizeof(BMP_HEADER));
|
||||
bmph.bfType=19778;
|
||||
bmph.bfSize=sizeof(BMP_HEADER);
|
||||
bmph.bfSize+=w*h*d/8;
|
||||
if (pPal)
|
||||
{
|
||||
bmph.bfSize+=(256*4);
|
||||
}
|
||||
bmph.bfOffBits=sizeof(BMP_HEADER);
|
||||
if (pPal)
|
||||
{
|
||||
bmph.bfOffBits+=(256*4);
|
||||
}
|
||||
bmph.biSize=40;//sizeof(BMP_HEADER);
|
||||
bmph.biWidth=w;
|
||||
bmph.biHeight=h;
|
||||
bmph.biPlanes=1;
|
||||
bmph.biBitCount=(unsigned short)d;
|
||||
bmph.biCompression=0;
|
||||
bmph.biSizeImage=w*h*d/8;
|
||||
|
||||
fwrite(&bmph,1,sizeof(BMP_HEADER),file);
|
||||
if (pPal)
|
||||
{
|
||||
for(i=0 ; i<256 ; i++)
|
||||
{
|
||||
fwrite(&pPal[i*3+0],1,1,file);
|
||||
fwrite(&pPal[i*3+1],1,1,file);
|
||||
fwrite(&pPal[i*3+2],1,1,file);
|
||||
fwrite(&pPal[i*3+2],1,1,file);
|
||||
}
|
||||
}
|
||||
slsize=w*d/8;
|
||||
scanline=(unsigned char*)Pic_calloc(1,slsize);
|
||||
if (!scanline)
|
||||
{
|
||||
Pic_SetError("BMP_Write, not enough memory for scanline");
|
||||
return(0);
|
||||
}
|
||||
for(rest=0 ; ((w*d/8)+rest)%4!=0 ; rest++);
|
||||
for(y=0 ; y<(long)h ; y++)
|
||||
{
|
||||
memcpy(scanline,&pDatas[(h-y-1)*slsize],slsize);
|
||||
if (d==24)
|
||||
{
|
||||
for(x=0 ; x<(long)w ; x++)
|
||||
{
|
||||
b=scanline[x*3+0];
|
||||
g=scanline[x*3+1];
|
||||
r=scanline[x*3+2];
|
||||
scanline[x*3+0]=b;
|
||||
scanline[x*3+1]=g;
|
||||
scanline[x*3+2]=r;
|
||||
}
|
||||
}
|
||||
fwrite(scanline,1,slsize,file);
|
||||
if (rest)
|
||||
{
|
||||
fwrite(scanline,1,rest,file);
|
||||
}
|
||||
}
|
||||
Pic_free(scanline);
|
||||
fclose(file);
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_BMP_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pWidth, unsigned long *pHeight,
|
||||
unsigned long *pDepth)
|
||||
{
|
||||
FILE *file;
|
||||
BMP_HEADER bmph;
|
||||
char *pPal;
|
||||
char *pDatas;
|
||||
unsigned char *scanline;
|
||||
long w,h,d;
|
||||
long i,x,y,rest;
|
||||
unsigned char r,g,b;
|
||||
unsigned char pad[4];
|
||||
|
||||
pPal=NULL;
|
||||
pDatas=NULL;
|
||||
file=fopen(FileName,"rb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("BMP_Read, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
fread(&bmph,1,sizeof(BMP_HEADER),file);
|
||||
*pWidth=w=bmph.biWidth;
|
||||
*pHeight=h=bmph.biHeight;
|
||||
*pDepth=d=bmph.biBitCount;
|
||||
if (d!=8 && d!=24)
|
||||
{
|
||||
Pic_SetError("BMP_Read, number of bits per pixel unsupported");
|
||||
return(0);
|
||||
}
|
||||
if (*pDepth==8)
|
||||
{
|
||||
pPal=(char*)Pic_calloc(1,256*3);
|
||||
if (!pPal)
|
||||
{
|
||||
Pic_SetError("BMP_Read, not enough memory for palette");
|
||||
return(0);
|
||||
}
|
||||
for(i=0 ; i<256 ; i++)
|
||||
{
|
||||
fread(&pPal[i*3+2],1,1,file);
|
||||
fread(&pPal[i*3+1],1,1,file);
|
||||
fread(&pPal[i*3+0],1,1,file);
|
||||
fread(&pad[0],1,1,file);
|
||||
}
|
||||
}
|
||||
pDatas=(char*)Pic_calloc(1,w*h*d/8);
|
||||
if (!pDatas)
|
||||
{
|
||||
if (pPal)
|
||||
{
|
||||
Pic_free(pPal);
|
||||
}
|
||||
Pic_SetError("BMP_Read, not enough memory for datas");
|
||||
return(0);
|
||||
}
|
||||
scanline=(unsigned char*)Pic_calloc(1,w*h*d/8);
|
||||
if (!scanline)
|
||||
{
|
||||
if (pPal)
|
||||
{
|
||||
Pic_free(pPal);
|
||||
}
|
||||
Pic_free(pDatas);
|
||||
Pic_SetError("BMP_Read, not enough memory for scanline");
|
||||
return(0);
|
||||
}
|
||||
for(rest=0 ; (w+rest)%4!=0 ; rest++);
|
||||
for(y=0 ; y<h ; y++)
|
||||
{
|
||||
fread(scanline,w,d/8,file);
|
||||
if (d==24)
|
||||
{
|
||||
for(x=0 ; x<w ; x++)
|
||||
{
|
||||
r=scanline[x*3+0];
|
||||
g=scanline[x*3+1];
|
||||
b=scanline[x*3+2];
|
||||
scanline[x*3+0]=b;
|
||||
scanline[x*3+1]=g;
|
||||
scanline[x*3+2]=r;
|
||||
}
|
||||
}
|
||||
memcpy(&pDatas[(h-y-1)*w*d/8],scanline,w*d/8);
|
||||
fread(pad,rest,d/8,file);
|
||||
}
|
||||
fclose(file);
|
||||
Pic_free(scanline);
|
||||
*ppPal=pPal;
|
||||
*ppDatas=pDatas;
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
@ -1,160 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <jpeglib.h>
|
||||
#include "pic_private.h"
|
||||
#include "pic.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct my_error_mgr
|
||||
{
|
||||
struct jpeg_error_mgr pub;
|
||||
jmp_buf setjmp_buffer;
|
||||
};
|
||||
typedef struct my_error_mgr * my_error_ptr;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static unsigned char error;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void my_error_exit(j_common_ptr cinfo)
|
||||
{
|
||||
my_error_ptr myerr = (my_error_ptr) cinfo->err;
|
||||
error=1;
|
||||
longjmp(myerr->setjmp_buffer, 1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_JPG_Read(const char *FileName, char **ppPal, char **ppDatas, unsigned long *w, unsigned long *h)
|
||||
{
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *file;
|
||||
JSAMPARRAY buffer;
|
||||
int row_stride,i;
|
||||
char *pDatas,*pPal;
|
||||
unsigned long ptr;
|
||||
|
||||
error=0;
|
||||
ptr=0;
|
||||
file=fopen(FileName, "rb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("JPG_Read, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
setjmp(jerr.setjmp_buffer);
|
||||
if (error)
|
||||
{
|
||||
Pic_SetError("JPG_Read, internal decompression error");
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return(0);
|
||||
}
|
||||
jpeg_create_decompress(&cinfo);
|
||||
jpeg_stdio_src(&cinfo, file);
|
||||
(void) jpeg_read_header(&cinfo, TRUE);
|
||||
*w=cinfo.image_width;
|
||||
*h=cinfo.image_height;
|
||||
if (!ppPal)
|
||||
{
|
||||
pDatas=(char*)Pic_calloc(1,(*w)*(*h)*3);
|
||||
}
|
||||
else
|
||||
{
|
||||
pDatas=(char*)Pic_calloc(1,(*w)*(*h));
|
||||
pPal=(char*)Pic_calloc(1,256*3);
|
||||
if (!pPal)
|
||||
{
|
||||
Pic_SetError("JPG_Read, not enough memory for palette");
|
||||
return(0);
|
||||
}
|
||||
cinfo.desired_number_of_colors = 256;
|
||||
cinfo.quantize_colors = TRUE;
|
||||
cinfo.dither_mode = JDITHER_ORDERED;
|
||||
}
|
||||
if (!pDatas)
|
||||
{
|
||||
Pic_SetError("JPG_Read, not enough memory for pic");
|
||||
return(0);
|
||||
}
|
||||
(void) jpeg_start_decompress(&cinfo);
|
||||
row_stride = cinfo.output_width * cinfo.output_components;
|
||||
buffer = (*cinfo.mem->alloc_sarray)
|
||||
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
|
||||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
(void) jpeg_read_scanlines(&cinfo, buffer, 1);
|
||||
memcpy(&pDatas[ptr],buffer[0],row_stride);
|
||||
ptr+=row_stride;
|
||||
}
|
||||
*ppDatas=pDatas;
|
||||
if (ppPal)
|
||||
{
|
||||
for(i=0 ; i<256 ; i++)
|
||||
{
|
||||
pPal[i*3+0]=cinfo.colormap[2][i];
|
||||
pPal[i*3+1]=cinfo.colormap[1][i];
|
||||
pPal[i*3+2]=cinfo.colormap[0][i];
|
||||
}
|
||||
*ppPal=pPal;
|
||||
}
|
||||
(void) jpeg_finish_decompress(&cinfo);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
fclose(file);
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_JPG_Write(const char *FileName, unsigned long Qual, char *pDatas, unsigned long w, unsigned long h)
|
||||
{
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *file;
|
||||
JSAMPROW row_pointer[1];
|
||||
int row_stride;
|
||||
|
||||
error=0;
|
||||
file=fopen(FileName,"wb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("JPG_Write, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
jpeg_create_compress(&cinfo);
|
||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
setjmp(jerr.setjmp_buffer);
|
||||
if (error)
|
||||
{
|
||||
Pic_SetError("JPG_Write, internal compression error");
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
return(0);
|
||||
}
|
||||
jpeg_stdio_dest(&cinfo, file);
|
||||
cinfo.image_width = w;
|
||||
cinfo.image_height = h;
|
||||
cinfo.input_components = 3;
|
||||
cinfo.in_color_space = JCS_RGB;
|
||||
jpeg_set_defaults(&cinfo);
|
||||
jpeg_set_quality(&cinfo, Qual, TRUE);
|
||||
jpeg_start_compress(&cinfo, TRUE);
|
||||
row_stride = w * 3;
|
||||
while(cinfo.next_scanline<cinfo.image_height)
|
||||
{
|
||||
row_pointer[0] = (JSAMPROW)& pDatas[cinfo.next_scanline * row_stride];
|
||||
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
}
|
||||
jpeg_finish_compress(&cinfo);
|
||||
fclose(file);
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
return(1);
|
||||
}
|
@ -1,637 +0,0 @@
|
||||
#include <string.h>
|
||||
#include "pic_private.h"
|
||||
#include "pic.h"
|
||||
|
||||
static unsigned long NbPics=0;
|
||||
static PIC_PICTURE *HeadPic=NULL;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static PIC_PICTURE *GetPic(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
|
||||
for(pic=HeadPic ; pic ; pic=pic->Next)
|
||||
{
|
||||
if (pic->ID==id)
|
||||
{
|
||||
return(pic);
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long PIC_Load(char* FileName, unsigned char Quantize)
|
||||
{
|
||||
char ext[4];
|
||||
unsigned long type;
|
||||
unsigned long i,taken,id;
|
||||
PIC_PICTURE *pic;
|
||||
char *pDatas;
|
||||
char *pPal;
|
||||
unsigned long w,h,Depth;
|
||||
unsigned long ret;
|
||||
|
||||
// --- Init
|
||||
ret=0;
|
||||
type=0;
|
||||
id=0;
|
||||
taken=0;
|
||||
w=0;
|
||||
h=0;
|
||||
Depth=0;
|
||||
pic=NULL;
|
||||
pDatas=NULL;
|
||||
pPal=NULL;
|
||||
// --- Get 1st available ID
|
||||
for(i=1 ; i<=NbPics+1 ; i++)
|
||||
{
|
||||
taken=0;
|
||||
for(pic=HeadPic ; pic ; pic=pic->Next)
|
||||
{
|
||||
if (pic->ID==i)
|
||||
{
|
||||
taken=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!taken)
|
||||
{
|
||||
id=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!id)
|
||||
{
|
||||
Pic_SetError("Load, unable to create ID");
|
||||
return(0);
|
||||
}
|
||||
// --- Load pic
|
||||
if (FileName)
|
||||
{
|
||||
ext[0]=FileName[strlen(FileName)-3];
|
||||
ext[1]=FileName[strlen(FileName)-2];
|
||||
ext[2]=FileName[strlen(FileName)-1];
|
||||
ext[3]=0;
|
||||
strupr(ext);
|
||||
if ( !strcmp(ext,"JPG") )
|
||||
{
|
||||
type=1;
|
||||
}
|
||||
else if ( !strcmp(ext,"TGA") )
|
||||
{
|
||||
type=2;
|
||||
}
|
||||
else if ( !strcmp(ext,"BMP") )
|
||||
{
|
||||
type=3;
|
||||
}
|
||||
|
||||
switch(type)
|
||||
{
|
||||
// - JPG
|
||||
case 1:
|
||||
if (!Quantize)
|
||||
{
|
||||
Depth=24;
|
||||
ret=Pic_JPG_Read(FileName,NULL,&pDatas,&w,&h);
|
||||
}
|
||||
else
|
||||
{
|
||||
Depth=8;
|
||||
ret=Pic_JPG_Read(FileName,&pPal,&pDatas,&w,&h);
|
||||
}
|
||||
if (!ret)
|
||||
{
|
||||
Pic_SetError("Load, unable to load JPG file %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
break;
|
||||
// - TGA
|
||||
case 2:
|
||||
ret=Pic_TGA_Read(FileName,&pPal,&pDatas,&w,&h,&Depth);
|
||||
if (!ret)
|
||||
{
|
||||
Pic_SetError("Load, unable to load TGA file %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
break;
|
||||
// - BMP
|
||||
case 3:
|
||||
ret=Pic_BMP_Read(FileName,&pPal,&pDatas,&w,&h,&Depth);
|
||||
if (!ret)
|
||||
{
|
||||
Pic_SetError("Load, unable to load BMP file %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
break;
|
||||
// - Unknown
|
||||
default:
|
||||
Pic_SetError("Load, unknown extension for %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Create and place new pic struct
|
||||
pic=(PIC_PICTURE *)Pic_calloc(1,sizeof(PIC_PICTURE));
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Load, not enough memory for internal structure");
|
||||
return(0);
|
||||
}
|
||||
pic->Next=HeadPic;
|
||||
HeadPic=pic;
|
||||
NbPics++;
|
||||
pic->ID=id;
|
||||
pic->pDatas=pDatas;
|
||||
pic->pPal=pPal;
|
||||
pic->Width=w;
|
||||
pic->Height=h;
|
||||
pic->Depth=Depth;
|
||||
return(id);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long PIC_Create(char* pPal, char* pDatas, unsigned long w, unsigned long h, unsigned long d)
|
||||
{
|
||||
unsigned long i,taken,id;
|
||||
PIC_PICTURE *pic;
|
||||
|
||||
// --- Init
|
||||
id=0;
|
||||
taken=0;
|
||||
pic=NULL;
|
||||
// --- Get 1st available ID
|
||||
for(i=1 ; i<=NbPics+1 ; i++)
|
||||
{
|
||||
taken=0;
|
||||
for(pic=HeadPic ; pic ; pic=pic->Next)
|
||||
{
|
||||
if (pic->ID==i)
|
||||
{
|
||||
taken=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!taken)
|
||||
{
|
||||
id=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!id)
|
||||
{
|
||||
Pic_SetError("Create, unable to create ID");
|
||||
return(0);
|
||||
}
|
||||
// --- Create pic
|
||||
if (!pDatas)
|
||||
{
|
||||
pDatas=(char *)Pic_calloc(1,w*h*d/8);
|
||||
if (!pDatas)
|
||||
{
|
||||
Pic_SetError("Create, not enough memory for datas");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if (d==8)
|
||||
{
|
||||
if (!pPal)
|
||||
{
|
||||
pPal=(char *)Pic_calloc(1,256*3);
|
||||
if (!pPal)
|
||||
{
|
||||
Pic_SetError("Create, not enough memory for palette");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pPal=NULL;
|
||||
}
|
||||
// --- Create and place new pic struct
|
||||
pic=(PIC_PICTURE *)Pic_calloc(1,sizeof(PIC_PICTURE));
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Create, not enough memory for internal structure");
|
||||
return(0);
|
||||
}
|
||||
pic->Next=HeadPic;
|
||||
HeadPic=pic;
|
||||
NbPics++;
|
||||
pic->ID=id;
|
||||
pic->pDatas=pDatas;
|
||||
pic->pPal=pPal;
|
||||
pic->Width=w;
|
||||
pic->Height=h;
|
||||
pic->Depth=d;
|
||||
return(id);
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long PIC_GetInfos( unsigned long id,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pW, unsigned long *pH, unsigned long *pD)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("GetInfos, picture internal structure not found");
|
||||
return(0);
|
||||
}
|
||||
if (ppPal)
|
||||
{
|
||||
*ppPal=pic->pPal;
|
||||
}
|
||||
if (ppDatas)
|
||||
{
|
||||
*ppDatas=pic->pDatas;
|
||||
}
|
||||
if (pW)
|
||||
{
|
||||
*pW=pic->Width;
|
||||
}
|
||||
if (pH)
|
||||
{
|
||||
*pH=pic->Height;
|
||||
}
|
||||
if (pD)
|
||||
{
|
||||
*pD=pic->Depth;
|
||||
}
|
||||
return(id);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static char* Conv8To24(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
char *buf;
|
||||
unsigned long i;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Conv8To24, picture internal structure not found");
|
||||
return(NULL);
|
||||
}
|
||||
buf=(char *)Pic_malloc(pic->Width*pic->Height*3);
|
||||
if (!buf)
|
||||
{
|
||||
Pic_SetError("Conv8To24, not enough memory for temporary buffer");
|
||||
return(NULL);
|
||||
}
|
||||
for(i=0 ; i<pic->Width*pic->Height ; i++)
|
||||
{
|
||||
buf[i*3+0]=pic->pPal[pic->pDatas[i]*3+0];
|
||||
buf[i*3+1]=pic->pPal[pic->pDatas[i]*3+1];
|
||||
buf[i*3+2]=pic->pPal[pic->pDatas[i]*3+2];
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
static char* Conv8To16(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
unsigned short *buf;
|
||||
unsigned long i;
|
||||
unsigned short r,g,b,pix16;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Conv8To24, picture internal structure not found");
|
||||
return(NULL);
|
||||
}
|
||||
buf=(unsigned short*)Pic_malloc(pic->Width*pic->Height*2);
|
||||
if (!buf)
|
||||
{
|
||||
Pic_SetError("Conv8To24, not enough memory for temporary buffer");
|
||||
return(NULL);
|
||||
}
|
||||
for(i=0 ; i<pic->Width*pic->Height ; i++)
|
||||
{
|
||||
b=pic->pPal[pic->pDatas[i]*3+0];
|
||||
g=pic->pPal[pic->pDatas[i]*3+1];
|
||||
r=pic->pPal[pic->pDatas[i]*3+2];
|
||||
r>>=3;
|
||||
g>>=3; g&=0x3E;
|
||||
b>>=3;
|
||||
pix16=(r<<10)+(g<<5)+b;
|
||||
buf[i]=pix16;
|
||||
}
|
||||
return (char*)buf;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
static char* Conv16To24(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
unsigned short *pDatas;
|
||||
unsigned char *buf;
|
||||
unsigned long i;
|
||||
unsigned short r,g,b;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Conv16To24, picture internal structure not found");
|
||||
return(NULL);
|
||||
}
|
||||
buf=(unsigned char *)Pic_malloc(pic->Width*pic->Height*3);
|
||||
if (!buf)
|
||||
{
|
||||
Pic_SetError("Conv16To24, not enough memory for temporary buffer");
|
||||
return(NULL);
|
||||
}
|
||||
pDatas=(unsigned short*)pic->pDatas;
|
||||
for(i=0 ; i<pic->Width*pic->Height ; i++)
|
||||
{
|
||||
r=(pDatas[i] & 0x7C00)>>(10-3);
|
||||
g=(pDatas[i] & 0x03E0)>>(5-3);
|
||||
b=(pDatas[i] & 0x001F)<<3;
|
||||
buf[i*3+0]=(unsigned char)r;
|
||||
buf[i*3+1]=(unsigned char)g;
|
||||
buf[i*3+2]=(unsigned char)b;
|
||||
}
|
||||
return (char*)buf;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
static char* Conv24To16(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
unsigned short *buf;
|
||||
unsigned long i;
|
||||
unsigned short r,g,b;
|
||||
unsigned short pix16;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Conv24To16, picture internal structure not found");
|
||||
return(NULL);
|
||||
}
|
||||
buf=(unsigned short*)Pic_malloc(pic->Width*pic->Height*2);
|
||||
if (!buf)
|
||||
{
|
||||
Pic_SetError("Conv24To16, not enough memory for temporary buffer");
|
||||
return(NULL);
|
||||
}
|
||||
for(i=0 ; i<pic->Width*pic->Height ; i++)
|
||||
{
|
||||
r=pic->pDatas[i*3+0];
|
||||
g=pic->pDatas[i*3+1];
|
||||
b=pic->pDatas[i*3+2];
|
||||
// r : 5 bits forts (0x7C)
|
||||
// g : 5 bits (6e zapped) (0x3E)
|
||||
// b : 5 bits faibles (0x1F)
|
||||
r>>=3;
|
||||
g>>=3; g&=0x3E;
|
||||
b>>=3;
|
||||
pix16=(r<<10)+(g<<5)+b;
|
||||
buf[i]=pix16;
|
||||
}
|
||||
return (char*)buf;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
static char* ConvPic(PIC_PICTURE *pic, unsigned long type, char* pErr)
|
||||
{
|
||||
char *buf;
|
||||
unsigned long src,dst;
|
||||
|
||||
*pErr=0;
|
||||
buf=NULL;
|
||||
src=pic->Depth;
|
||||
if (type==PIC_TYPE_TGA8 || type==PIC_TYPE_BMP8)
|
||||
{
|
||||
dst=8;
|
||||
}
|
||||
if (type==PIC_TYPE_TGA16)
|
||||
{
|
||||
dst=16;
|
||||
}
|
||||
if (type==PIC_TYPE_JPG || type==PIC_TYPE_TGA24 || type==PIC_TYPE_BMP24)
|
||||
{
|
||||
dst=24;
|
||||
}
|
||||
// ---
|
||||
if (src==dst)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
// ---
|
||||
if (src==8 && dst==24)
|
||||
{
|
||||
buf=Conv8To24(pic->ID);
|
||||
if (!buf)
|
||||
{
|
||||
*pErr=1;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
if (src==8 && dst==16)
|
||||
{
|
||||
buf=Conv8To16(pic->ID);
|
||||
if (!buf)
|
||||
{
|
||||
*pErr=1;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
// ---
|
||||
if (src==16 && dst==24)
|
||||
{
|
||||
buf=Conv16To24(pic->ID);
|
||||
if (!buf)
|
||||
{
|
||||
*pErr=1;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
// ---
|
||||
if (src==24 && dst==16)
|
||||
{
|
||||
buf=Conv24To16(pic->ID);
|
||||
if (!buf)
|
||||
{
|
||||
*pErr=1;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
// ---
|
||||
if (src==24 && dst==8)
|
||||
{
|
||||
Pic_SetError("ConvPic, downsampling 24 to 8 bits unsupported");
|
||||
*pErr=1;
|
||||
return(NULL);
|
||||
}
|
||||
Pic_SetError("ConvPic, conversion %d to %d unsupported",src,dst);
|
||||
*pErr=1;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
unsigned long PIC_Save(unsigned long id, char* FileName, unsigned long type, unsigned long qual)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
char err;
|
||||
char *buf;
|
||||
char *freeit;
|
||||
unsigned long depth;
|
||||
|
||||
freeit=NULL;
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Save %s, picture internal structure not found",FileName);
|
||||
return(0);
|
||||
}
|
||||
freeit = ConvPic(pic,type,&err);
|
||||
if (err)
|
||||
{
|
||||
Pic_SetError("Save %s, error while converting picture",FileName);
|
||||
return(0);
|
||||
}
|
||||
if (!freeit)
|
||||
{
|
||||
buf=pic->pDatas;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf=freeit;
|
||||
}
|
||||
err=0;
|
||||
switch(type)
|
||||
{
|
||||
// ---
|
||||
case PIC_TYPE_JPG:
|
||||
if ( !Pic_JPG_Write(FileName,qual,buf,pic->Width,pic->Height) )
|
||||
{
|
||||
if (freeit)
|
||||
{
|
||||
Pic_free(buf);
|
||||
}
|
||||
Pic_SetError("Save %s, error while saving JPG file",FileName);
|
||||
err=1;
|
||||
}
|
||||
break;
|
||||
// ---
|
||||
case PIC_TYPE_TGA8:
|
||||
case PIC_TYPE_TGA16:
|
||||
case PIC_TYPE_TGA24:
|
||||
if (type==PIC_TYPE_TGA8)
|
||||
{
|
||||
depth=8;
|
||||
}
|
||||
if (type==PIC_TYPE_TGA16)
|
||||
{
|
||||
depth=16;
|
||||
}
|
||||
if (type==PIC_TYPE_TGA24)
|
||||
{
|
||||
depth=24;
|
||||
}
|
||||
if ( !Pic_TGA_Write(FileName,pic->pPal,buf,pic->Width,pic->Height,depth) )
|
||||
{
|
||||
if (freeit)
|
||||
{
|
||||
Pic_free(freeit);
|
||||
}
|
||||
Pic_SetError("Save %s, error while saving TGA file",FileName);
|
||||
err=1;
|
||||
}
|
||||
break;
|
||||
// ---
|
||||
case PIC_TYPE_BMP8:
|
||||
case PIC_TYPE_BMP24:
|
||||
if (type==PIC_TYPE_BMP8)
|
||||
{
|
||||
depth=8;
|
||||
}
|
||||
if (type==PIC_TYPE_BMP24)
|
||||
{
|
||||
depth=24;
|
||||
}
|
||||
if ( !Pic_BMP_Write(FileName,pic->pPal,buf,pic->Width,pic->Height,depth) )
|
||||
{
|
||||
if (freeit)
|
||||
{
|
||||
Pic_free(freeit);
|
||||
}
|
||||
Pic_SetError("Save %s, error while saving BMP file",FileName);
|
||||
err=1;
|
||||
}
|
||||
break;
|
||||
// ---
|
||||
default:
|
||||
Pic_SetError("Save %s, unknow save format/type",FileName);
|
||||
err=1;
|
||||
break;
|
||||
}
|
||||
if (freeit)
|
||||
{
|
||||
Pic_free(freeit);
|
||||
}
|
||||
return(err-1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long PIC_Destroy(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *prevpic,*pic;
|
||||
unsigned long found;
|
||||
|
||||
prevpic=NULL;
|
||||
found=0;
|
||||
for(pic=HeadPic ; pic ; pic=pic->Next)
|
||||
{
|
||||
if (pic->ID==id)
|
||||
{
|
||||
found=1;
|
||||
break;
|
||||
}
|
||||
prevpic=pic;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
Pic_SetError("Destroy, picture internal structure not found");
|
||||
return(0);
|
||||
}
|
||||
if (prevpic)
|
||||
{
|
||||
prevpic->Next=pic->Next;
|
||||
}
|
||||
if (pic->pDatas)
|
||||
{
|
||||
Pic_free(pic->pDatas);
|
||||
}
|
||||
if (pic->pPal)
|
||||
{
|
||||
Pic_free(pic->pPal);
|
||||
}
|
||||
if (pic==HeadPic)
|
||||
{
|
||||
HeadPic=pic->Next;
|
||||
}
|
||||
Pic_free(pic);
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
@ -1,215 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pic_private.h"
|
||||
#include "pic.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct TGA_HEADER
|
||||
{
|
||||
unsigned char LengthID;
|
||||
unsigned char CMapType;
|
||||
unsigned char ImageType;
|
||||
unsigned short Origin;
|
||||
unsigned short Length;
|
||||
unsigned char Depth;
|
||||
unsigned short XOrg;
|
||||
unsigned short YOrg;
|
||||
unsigned short Width;
|
||||
unsigned short Height;
|
||||
unsigned char ImageDepth;
|
||||
unsigned char Desc;
|
||||
} TGA_HEADER;
|
||||
#pragma pack()
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_TGA_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pWidth, unsigned long *pHeight,
|
||||
unsigned long *pDepth)
|
||||
{
|
||||
FILE *file;
|
||||
TGA_HEADER tgah;
|
||||
long w,h,d;
|
||||
unsigned long size;
|
||||
char *pDatas;
|
||||
char *pPal;
|
||||
long x,y;
|
||||
long slsize;
|
||||
unsigned char *scanline;
|
||||
unsigned char r,g,b;
|
||||
long i;
|
||||
int upSideDown;
|
||||
|
||||
pDatas=NULL;
|
||||
pPal=NULL;
|
||||
file=fopen(FileName,"rb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("TGA_Read, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
fread(&tgah,1,sizeof(TGA_HEADER),file);
|
||||
if (tgah.ImageType>3)
|
||||
{
|
||||
Pic_SetError("TGA_Read, unsupported TGA format");
|
||||
return(0);
|
||||
}
|
||||
*pWidth=w=tgah.Width;
|
||||
*pHeight=h=tgah.Height;
|
||||
*pDepth=d=tgah.ImageDepth;
|
||||
upSideDown = ((tgah.Desc & (1 << 5))==0);
|
||||
|
||||
size=tgah.Width*tgah.Height*(tgah.ImageDepth/8);
|
||||
pDatas=(char*)Pic_malloc(size);
|
||||
if (!pDatas)
|
||||
{
|
||||
Pic_SetError("TGA_Read, not enough memory");
|
||||
return(0);
|
||||
}
|
||||
if (*pDepth==8)
|
||||
{
|
||||
if (!ppPal)
|
||||
{
|
||||
Pic_free(pDatas);
|
||||
Pic_SetError("TGA_Read, need a pointer to palette");
|
||||
return(0);
|
||||
}
|
||||
pPal=(char*)Pic_calloc(1,256*3);
|
||||
if (!pPal)
|
||||
{
|
||||
Pic_SetError("TGA_Read, not enough memory for palette");
|
||||
return(0);
|
||||
}
|
||||
if (tgah.ImageType==1)
|
||||
{
|
||||
for(i=0 ; i<256*3 ; i+=3)
|
||||
{
|
||||
fread(&pPal[i+2],1,1,file);
|
||||
fread(&pPal[i+1],1,1,file);
|
||||
fread(&pPal[i+0],1,1,file);
|
||||
}
|
||||
}
|
||||
*ppPal=pPal;
|
||||
}
|
||||
|
||||
slsize=w*d/8;
|
||||
scanline=(unsigned char*)Pic_calloc(1,slsize);
|
||||
if (!scanline)
|
||||
{
|
||||
if (pPal)
|
||||
{
|
||||
Pic_free(pPal);
|
||||
}
|
||||
Pic_free(pDatas);
|
||||
Pic_SetError("TGA_Read, not enough memory for scanline");
|
||||
return(0);
|
||||
}
|
||||
for(y=0 ; y<h ; y++)
|
||||
{
|
||||
fread(scanline,1,slsize,file);
|
||||
if (d==24 || d==32)
|
||||
{
|
||||
long mult=3;
|
||||
if(d==32) mult=4;
|
||||
for(x=0 ; x<w ; x++)
|
||||
{
|
||||
r=scanline[x*mult+0];
|
||||
g=scanline[x*mult+1];
|
||||
b=scanline[x*mult+2];
|
||||
scanline[x*mult+0]=b;
|
||||
scanline[x*mult+1]=g;
|
||||
scanline[x*mult+2]=r;
|
||||
}
|
||||
}
|
||||
if (upSideDown)
|
||||
memcpy(&pDatas[(h-y-1)*slsize], scanline, slsize);
|
||||
else
|
||||
memcpy(&pDatas[(y)*slsize], scanline, slsize);
|
||||
}
|
||||
Pic_free(scanline);
|
||||
fclose(file);
|
||||
*ppDatas=pDatas;
|
||||
return(1);
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_TGA_Write( const char *FileName,
|
||||
char *pPal, char *pDatas,
|
||||
unsigned long w, unsigned long h, unsigned long d)
|
||||
{
|
||||
FILE *file;
|
||||
TGA_HEADER tgah;
|
||||
long x,y;
|
||||
long slsize;
|
||||
unsigned char *scanline;
|
||||
unsigned char r,g,b;
|
||||
|
||||
file=fopen(FileName,"wb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("TGA_Write, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
memset(&tgah,0,sizeof(TGA_HEADER));
|
||||
tgah.LengthID=0;
|
||||
if (d>8)
|
||||
{
|
||||
tgah.CMapType=0;
|
||||
tgah.ImageType=2;
|
||||
tgah.Length=0;
|
||||
tgah.Depth=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tgah.CMapType=1;
|
||||
tgah.ImageType=1;
|
||||
tgah.Length=256;
|
||||
tgah.Depth=24;
|
||||
}
|
||||
tgah.Origin=0;
|
||||
tgah.XOrg=0;
|
||||
tgah.YOrg=0;
|
||||
tgah.Width=(unsigned short)w;
|
||||
tgah.Height=(unsigned short)h;
|
||||
tgah.ImageDepth=(unsigned char)d;
|
||||
tgah.Desc=0;
|
||||
fwrite(&tgah,1,sizeof(TGA_HEADER),file);
|
||||
if (d==8)
|
||||
{
|
||||
fwrite(pPal,1,256*3,file);
|
||||
}
|
||||
slsize=w*d/8;
|
||||
scanline=(unsigned char*)Pic_calloc(1,slsize);
|
||||
if (!scanline)
|
||||
{
|
||||
Pic_SetError("TGA_Write, not enough memory for scanline");
|
||||
return(0);
|
||||
}
|
||||
for(y=0 ; y<(long)h ; y++)
|
||||
{
|
||||
memcpy(scanline,&pDatas[(h-y-1)*slsize],slsize);
|
||||
if (d==24)
|
||||
{
|
||||
for(x=0 ; x<(long)w ; x++)
|
||||
{
|
||||
r=scanline[x*3+0];
|
||||
g=scanline[x*3+1];
|
||||
b=scanline[x*3+2];
|
||||
scanline[x*3+0]=b;
|
||||
scanline[x*3+1]=g;
|
||||
scanline[x*3+2]=r;
|
||||
}
|
||||
}
|
||||
fwrite(scanline,1,slsize,file);
|
||||
}
|
||||
Pic_free(scanline);
|
||||
fclose(file);
|
||||
return(1);
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _PIC_H_
|
||||
#define _PIC_H_
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define PIC_TYPE_JPG 1
|
||||
#define PIC_TYPE_TGA8 2
|
||||
#define PIC_TYPE_TGA16 3
|
||||
#define PIC_TYPE_TGA24 4
|
||||
#define PIC_TYPE_BMP8 5
|
||||
#define PIC_TYPE_BMP24 6
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Basic API
|
||||
//
|
||||
extern unsigned long PIC_Load(char* FileName, unsigned char Quantize);
|
||||
|
||||
extern unsigned long PIC_Create(char* pPal, char* pDatas, unsigned long w, unsigned long h, unsigned long d);
|
||||
|
||||
extern unsigned long PIC_Save(unsigned long id, char* FileName, unsigned long type, unsigned long qual);
|
||||
|
||||
extern unsigned long PIC_GetInfos( unsigned long id,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pW, unsigned long *pH, unsigned long *pD);
|
||||
|
||||
|
||||
extern unsigned long PIC_Destroy(unsigned long id);
|
||||
//
|
||||
// System
|
||||
//
|
||||
extern unsigned long PIC_GetMemNbAllocs(void);
|
||||
extern unsigned long PIC_GetMemAllocated(void);
|
||||
extern char* PIC_GetError(void);
|
||||
extern unsigned char PIC_Error(void);
|
||||
extern void PIC_ResetError(void);
|
||||
extern unsigned char PIC_OnErrorCall( void pFnct(void) );
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
@ -1,81 +0,0 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _PIC_PRIVATE_H_
|
||||
#define _PIC_PRIVATE_H_
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct PIC_PICTURE
|
||||
{
|
||||
unsigned long ID;
|
||||
unsigned long Width;
|
||||
unsigned long Height;
|
||||
unsigned long Depth;
|
||||
char *pDatas;
|
||||
char *pPal;
|
||||
struct PIC_PICTURE *Next;
|
||||
} PIC_PICTURE;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//
|
||||
// JPG
|
||||
//
|
||||
|
||||
|
||||
extern unsigned long Pic_JPG_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *w, unsigned long *h);
|
||||
|
||||
extern unsigned long Pic_JPG_Write( const char *FileName,
|
||||
unsigned long Qual,
|
||||
char *pDatas,
|
||||
unsigned long w, unsigned long h);
|
||||
//
|
||||
// TGA
|
||||
//
|
||||
extern unsigned long Pic_TGA_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pWidth, unsigned long *pHeight,
|
||||
unsigned long *pDepth);
|
||||
extern unsigned long Pic_TGA_Write( const char *FileName,
|
||||
char *pPal, char *pDatas,
|
||||
unsigned long w, unsigned long h, unsigned long d);
|
||||
//
|
||||
// BMP
|
||||
//
|
||||
extern unsigned long Pic_BMP_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pWidth, unsigned long *pHeight,
|
||||
unsigned long *pDepth);
|
||||
|
||||
extern unsigned long Pic_BMP_Write( const char *FileName,
|
||||
char *pPal, char *pDatas,
|
||||
unsigned long w, unsigned long h, unsigned long d);
|
||||
//
|
||||
// System
|
||||
//
|
||||
extern void* Pic_malloc(unsigned long size);
|
||||
extern void* Pic_calloc(unsigned long count, unsigned long size);
|
||||
extern void Pic_free(void *memblock);
|
||||
extern unsigned long Pic__msize(void *memblock);
|
||||
extern void Pic_SetError(const char *msg, ...);
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
@ -1,84 +0,0 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
#include "readpic.h"
|
||||
#include "pic.h"
|
||||
#include <nel/misc/rgba.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//============================================================
|
||||
// Image API.
|
||||
//============================================================
|
||||
|
||||
|
||||
bool PIC_LoadPic(string path, vector<NLMISC::CBGRA> &tampon, uint &Width, uint &Height)
|
||||
{
|
||||
uint32 id;
|
||||
char *pal, *data;
|
||||
unsigned long w,h,depth;
|
||||
uint i;
|
||||
|
||||
|
||||
// Loadons l'image.
|
||||
id= PIC_Load((char*)path.c_str(), 0);
|
||||
if(id==0)
|
||||
return false;
|
||||
PIC_GetInfos( id, &pal, &data, &w, &h, &depth);
|
||||
Width=w;
|
||||
Height=h;
|
||||
|
||||
// On traduit en RGBA.
|
||||
tampon.resize(w*h);
|
||||
switch(depth)
|
||||
{
|
||||
case 8:
|
||||
for(i=0;i<w*h;i++)
|
||||
{
|
||||
tampon[i].R= data[i];
|
||||
tampon[i].G= data[i];
|
||||
tampon[i].B= data[i];
|
||||
tampon[i].A= data[i];
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
for(i=0;i<w*h;i++)
|
||||
{
|
||||
tampon[i].R= data[i*3+ 0];
|
||||
tampon[i].G= data[i*3+ 1];
|
||||
tampon[i].B= data[i*3+ 2];
|
||||
tampon[i].A= 255;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
for(i=0;i<w*h;i++)
|
||||
{
|
||||
tampon[i].R= data[i*4+ 0];
|
||||
tampon[i].G= data[i*4+ 1];
|
||||
tampon[i].B= data[i*4+ 2];
|
||||
tampon[i].A= data[i*4+ 3];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// On ferme.
|
||||
PIC_Destroy(id);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _READPIC_H_
|
||||
#define _READPIC_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include <nel/misc/rgba.h>
|
||||
|
||||
//============================================================
|
||||
// API.
|
||||
//============================================================
|
||||
|
||||
|
||||
bool PIC_LoadPic(std::string Path, std::vector<NLMISC::CBGRA> &Tampon, uint &Width, uint &Height);
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,11 @@
|
||||
title Ryzom Core: 1_export.py (LEVELDESIGN)
|
||||
1_export.py -ipj common/sky common/sfx common/gamedev common/data_common common/data_shard common/leveldesign common/exedll common/cfg shard/data_shard shard/data_language shard/data_leveldesign shard/data_game_share
|
||||
title Ryzom Core: 2_build.py (LEVELDESIGN)
|
||||
2_build.py -ipj common/sky common/sfx common/gamedev common/data_common common/data_shard common/leveldesign common/exedll common/cfg shard/data_shard shard/data_language shard/data_leveldesign shard/data_game_share
|
||||
title Ryzom Core: 3_install.py (LEVELDESIGN)
|
||||
3_install.py -ipj common/sky common/sfx common/gamedev common/data_common common/data_shard common/leveldesign common/exedll common/cfg shard/data_shard shard/data_language shard/data_leveldesign shard/data_game_share
|
||||
title Ryzom Core: b1_client_dev.py (LEVELDESIGN)
|
||||
b1_client_dev.py
|
||||
title Ryzom Core: b2_shard_data.py (LEVELDESIGN)
|
||||
b2_shard_data.py
|
||||
title Ryzom Core: Ready
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue