Changeset 4083 in Sophya for trunk/SophyaPI/PI/pipixmapgen.cc


Ignore:
Timestamp:
Oct 4, 2012, 2:26:28 PM (13 years ago)
Author:
garnier
Message:

Fichiers mis a jour en comparaison avec OnlyPI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pipixmapgen.cc

    r4077 r4083  
    88#include "sopnamsp.h"
    99#include "pipixmapgen.h"
     10
    1011
    1112// --------- Methodes de la classe PIPixMap  ----------
     
    4344// long  kind()
    4445//      Retourne le type ("=PIPixmap::ClassId")
    45 // void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0)
    46 //      Associe un tableau d'index "pix" de taille "sx * sy".
    47 //      (ox,oy)" définissent  l'offset d'affichage.
     46// void  SetPixmap(PIPixColIdx *pixidx, int sx, int sy, bool refr=true, int ox=0, int oy=0)
     47//      Associe un tableau d'index de couleur "pixidx". (ox,oy)" définissent  l'offset d'affichage.
    4848//      Si "refr=true", la méthode "Refresh()" est appelée.
    4949//--
     
    8787{
    8888pixmap = NULL;
    89 nx = ny = 0;
     89fgownpmap = false;
    9090ofx = ofy = 0;
    9191mPpos[0] = mPpos[0] = 0;
     
    9999{
    100100delete cmap;
     101if (fgownpmap && pixmap) delete pixmap;
    101102}
    102103
    103104/* --Methode-- */
    104 void PIPixmapGen::SetPixmap(unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)
     105void PIPixmapGen::SetPixmap(PIPixColIdx *pixidx, bool refr, int ox, int oy)
    105106{
    106 pixmap = pix;
    107 if (pixmap)
    108   {
    109   if (sx < 0)  sx = 0;
    110   if (sy < 0)  sy = 0;
    111   if (ox < 0)  ox = 0;
    112   if (oy < 0)  oy = 0;
    113   nx = sx; ny = sy;
    114   ofx = ox;  ofy = oy;
     107if (fgownpmap && pixmap) delete pixmap;
     108fgownpmap = false;
     109pixmap = pixidx;
     110if (ox < 0)  ox = 0;
     111if (oy < 0)  oy = 0;
     112ofx = ox;  ofy = oy;
     113if (refr) Refresh();   
     114}
     115
     116/* --Methode-- */
     117void PIPixmapGen::SetRGBArray(PIPixRGBArray *rgba, CMapId cmapid, bool refr, int ox, int oy)
     118{
     119if (rgba == NULL) return;
     120int quantum = 8;
     121if (cmapid == CMAP_RGB216)  quantum = 6;
     122else if (cmapid == CMAP_RGB4096) quantum = 16;
     123else cmapid = CMAP_RGB512;
     124SetColMapId(cmapid, false);
     125PIPixColIdx * pixc = new PIPixColIdx;
     126pixc->AllocateByte(rgba->XSize(), rgba->YSize());
     127for(int j=0; j<rgba->YSize(); j++)
     128  for(int i=0; i<rgba->XSize(); i++) {
     129        PIPixRGB vv = (*rgba)(i,j);
     130        int r = (int)vv.red*quantum/256;
     131        int g = (int)vv.green*quantum/256;
     132        int b = (int)vv.blue*quantum/256;
     133    pixc->GetShort(i,j) = (unsigned short)((b*quantum+g)*quantum+r);
    115134  }
    116 else { ofx = ofy = nx = ny = 0; }
    117 if (refr) Refresh();   
     135SetPixmap(pixc, refr, ox, oy);
     136fgownpmap = true;
     137return; 
    118138}
    119139
Note: See TracChangeset for help on using the changeset viewer.