void PutGrid(BITMAP * dc) { double yr = TO_RAD(Form1->TrackBarTilt->Position); float sin_y = Sin(ANGLE_Y); float cos_y = Cos(ANGLE_Y); float ScaleV_Y = sin_y; float ScaleV_XZ = cos_y; float sin_x = Sin(ANGLE_X); float cos_x = Cos(ANGLE_X); int PenCol; SET_PEN(dc,128,0,0); LINE(dc,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y, CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y,PenCol); LINE(dc,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ, CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ,PenCol); LINE(dc,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y, CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y,PenCol); LINE(dc ,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y ,CENTER+XGRID*cos_x,CENTER-XGRID*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y ,PenCol); LINE(dc ,CENTER+XGRID_2*cos_x,CENTER-XGRID_2*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y ,CENTER+XGRID_2*cos_x,CENTER-XGRID_2*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y ,PenCol); LINE(dc ,CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y ,CENTER-XGRID*cos_x,CENTER+XGRID*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y ,PenCol); LINE(dc ,CENTER-XGRID_2*cos_x,CENTER+XGRID_2*sin_x*ScaleV_XZ-XGRID_2*ScaleV_Y ,CENTER-XGRID_2*cos_x,CENTER+XGRID_2*sin_x*ScaleV_XZ+XGRID_2*ScaleV_Y ,PenCol); float sin_z = cos_x;//Sin(ANGLE_Z); float cos_z = sin_x;//Cos(ANGLE_Z); SET_PEN(dc,0,96,96);// SelectObject(dc,PenYellow); LINE(dc,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ - XGRID_2*ScaleV_Y, CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ - XGRID_2*ScaleV_Y,PenCol); LINE(dc,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ,//*ScaleV_Y , CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ /**ScaleV_Y*/ ,PenCol); LINE(dc,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ +XGRID_2*ScaleV_Y, CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ +XGRID_2*ScaleV_Y,PenCol); LINE(dc,CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ-XGRID_2*ScaleV_Y ,CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ+XGRID_2*ScaleV_Y ,PenCol); LINE(dc ,CENTER-XGRID_2*cos_z,CENTER-XGRID_2*sin_z*ScaleV_XZ-XGRID_2*ScaleV_Y ,CENTER-XGRID_2*cos_z,CENTER-XGRID_2*sin_z*ScaleV_XZ+XGRID_2*ScaleV_Y ,PenCol); LINE(dc,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ-XGRID_2*ScaleV_Y ,CENTER-XGRID*cos_z, CENTER - XGRID*sin_z*ScaleV_XZ+XGRID_2*ScaleV_Y ,PenCol); LINE(dc ,CENTER+XGRID_2*cos_z,CENTER+XGRID_2*sin_z*ScaleV_XZ-XGRID_2*ScaleV_Y ,CENTER+XGRID_2*cos_z,CENTER+XGRID_2*sin_z*ScaleV_XZ+XGRID_2*ScaleV_Y ,PenCol); SET_PEN(dc,64,64,64);// SelectObject(dc,PenYellow); LINE(dc,CENTER,CENTER-XGRID_2*ScaleV_Y, CENTER,CENTER+XGRID_2*ScaleV_Y,PenCol); circlefill(dc, CENTER+XGRID*cos_z, CENTER + XGRID*sin_z*ScaleV_XZ //*sin_y ,3,makecol24(0,128,0)); circlefill(dc, CENTER,CENTER-XGRID_2*ScaleV_Y ,3,makecol24(128,128,0)); }
CChannelN::CChannelN (TImage * pImg, TImage * pCodeImg, int n_Chan) { m_nCurPosition = 0; m_nChan=n_Chan; pImage = pImg; pCodeImage = pCodeImg; m_sSize.x=pImage->ClientRect.right; m_sSize.y=pImage->ClientRect.bottom; m_nVScale=Form1->VScale(); m_pnDisplayState = new long[m_sSize.x*m_nChan]; for (int i = 0; i < m_sSize.x*n_Chan; i++) { // m_pnDisplayState[i] = 0;//5- rand() %10; } allegro_init(); set_gdi_color_format(); install_keyboard(); install_mouse(); install_timer(); bmpCanvas = create_bitmap_ex(32,m_sSize.x,m_sSize.y); bmpCodeCanvas = create_bitmap_ex(32,pCodeImage->ClientRect.Width(),Form1->ImageCode->ClientRect.Height()); m_nColor=makecol24(0,255,255); PenYellow= CreatePen(PS_SOLID,1, 0x0000ff00); PenBlack = CreatePen(PS_SOLID,1, 0x00000000); PenGray = CreatePen(PS_SOLID,1, clGray); PenRed = CreatePen(PS_SOLID,1, clRed); }
void TDisplay3D::PaintBkgr() { rectfill(bmpCanvasBackground,0,0, bmpCanvasBackground->w, bmpCanvasBackground->h, makecol24(0,0,0)); PutGrid(bmpCanvasBackground); blit(bmpCanvasBackground, bmpCanvas, 0, 0, 0, 0, bmpCanvas->w, bmpCanvas->h); }
void TileMap::setTileFlags(int x, int y, int flags) { if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight()) { return; } int pixel = _getpixel24(mTileMapBitmap, x, y); int newPixel = makecol24(getr24(pixel), getg24(pixel), flags); _putpixel24(mTileMapBitmap, x, y, newPixel); }
void TileMap::setTile(int x, int y, int tileNumber) { if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight()) { return; } int pixel = _getpixel24(mTileMapBitmap, x, y); int newPixel = makecol24(tileNumber, getg24(pixel), getb24(pixel)); _putpixel24(mTileMapBitmap, x, y, newPixel); }
/* makeacol_depth: * Converts R, G, B, and A values (ranging 0-255) to whatever pixel format * is required by the specified color depth. */ int makeacol_depth(int color_depth, int r, int g, int b, int a) { switch (color_depth) { case 8: return makecol8(r, g, b); case 15: return makecol15(r, g, b); case 16: return makecol16(r, g, b); case 24: return makecol24(r, g, b); case 32: return makeacol32(r, g, b, a); } return 0; }
//second parameter is ignored void* load_level(PACKFILE *file,int size) { int i; LEVEL *data; data = calloc(1,sizeof(LEVEL)); //read small stuff and malloc things data->sizey = pack_igetw(file); data->sizex = pack_igetw(file); data->length = data->sizex * data->sizey; printf("sizex=%d, sizey=%d, length=%d", data->sizex, data->sizey, data->length); data->map = calloc(data->length,1); data->bgtype = pack_getc(file); if (data->bgtype == 1) for(i = 0;i < 600;i++) data->lines[i] = makecol24(pack_getc(file),pack_getc(file),pack_getc(file)); data->entitycnt = pack_igetw(file); data->entities = calloc(data->entitycnt,sizeof(ENTITY)); //do serios file magic pack_fread(data->map,data->length,file); for (i = 0;i < data->entitycnt;i++) { load_entity(file,&data->entities[i]); } return data; }
int convert_color_to_allegro<GrayscaleTraits, 24>(color_t c, const Palette* palette) { return makecol24(graya_getv(c), graya_getv(c), graya_getv(c)); }
int convert_color_to_allegro<RgbTraits, 24>(color_t c, const Palette* palette) { return makecol24(rgba_getr(c), rgba_getg(c), rgba_getb(c)); }
int convert_color_to_allegro<BitmapTraits, 24>(color_t color, const Palette* palette) { color_t c = palette->getEntry(color); return makecol24(rgba_getr(c), rgba_getg(c), rgba_getb(c)); }
void CChannelN::PaintBkgr() { rectfill(bmpCanvas,0,0,bmpCanvas->w,bmpCanvas->h, makecol24(0,0,0)); rectfill(bmpCodeCanvas,0,0,bmpCodeCanvas->w,bmpCodeCanvas->h, makecol24(0,0,0)); }
int TDisplay3D::DisplaySample(/*TDataRiver *sample*/double *sample, int nChannels, int channelsPerMarker, float samplingRate) { // TMaxArray * pMS = (TMaxArray * )sample; DCTYPE dc; GET_DC(dc); int PenCol; int pos1; double x,y,z; blit(bmpCanvasBackground, bmpCanvas, 0, 0, 0, 0, bmpCanvas->w, bmpCanvas->h); //int i = Form1->udMoCh->Position; if (zero) { x0 = sample[0];//GetValue(sample,i,0); y0 = sample[1];//GetValue(sample,i,1); z0 = sample[2];//GetValue(sample,i,2); zero=false; } int chCount = nChannels/channelsPerMarker; if (chCount > Form1->UpDown2->Position) chCount = Form1->UpDown2->Position; for (int ch = 0; ch < chCount; ch++) if (FormLEDs->CheckBoxLED[ch]->Checked) { x =(sample[ch*channelsPerMarker]-x0)* Form1->TrackBarGain->Position/100; y =(sample[1+ch*channelsPerMarker]-y0)* Form1->TrackBarGain->Position/100; z =(sample[2+ch*channelsPerMarker]-z0)* Form1->TrackBarGain->Position/100;; Display3DBuffer[ch].AddSample(x,y,z); pos1 = Display3DBuffer[ch].pos; int r = 255; int g = 255; if (x<0) r = 128; if (z<0) g = 128; int is3 = (ch % 3)==2; if (Form1->CheckBoxZY->Checked) { circlefill(dc, Display3DBuffer[ch].zy[pos1], Display3DBuffer[ch].yz[pos1], 4,makecol24(0,96,96)); if (Form1->CheckBoxXYZ->Checked) { SET_PEN(dc,180,0,0);// LINE(dc,Display3DBuffer[ch].xzy[pos1], Display3DBuffer[ch].yxz[pos1], Display3DBuffer[ch].zy[pos1], Display3DBuffer[ch].yz[pos1],PenCol); } } if (Form1->CheckBoxXY->Checked) { circlefill(dc, Display3DBuffer[ch].xy[pos1], Display3DBuffer[ch].yx[pos1], 4,makecol24(96,0,0)); if (Form1->CheckBoxXYZ->Checked) { SET_PEN(dc,0,96,96);// SelectObject(dc,PenYellow); LINE(dc,Display3DBuffer[ch].xzy[pos1], Display3DBuffer[ch].yxz[pos1], Display3DBuffer[ch].xy[pos1], Display3DBuffer[ch].yx[pos1],PenCol); } } if (Form1->CheckBoxXYZ->Checked) { static int n=0; circlefill(dc, Display3DBuffer[ch].xzy[pos1], Display3DBuffer[ch].yxz[pos1], 4,makecol24(255,255,0)); n++; if (n % 10 == 0) if (is3 && Form1->CheckBoxConn3->Checked) { SET_PEN(dc,0,255,0);// SelectObject(dc,PenYellow); LINE(dc, Display3DBuffer[ch-1].xzy[pos1], Display3DBuffer[ch-1].yxz[pos1], Display3DBuffer[ch].xzy[pos1], Display3DBuffer[ch].yxz[pos1], PenCol); SET_PEN(dc,0,255,255);// SelectObject(dc,PenYellow); LINE(dc, CENTER, CENTER, Display3DBuffer[ch-2].xzy[pos1], Display3DBuffer[ch-2].yxz[pos1], PenCol); } } } return 0;// does not matter }