Beispiel #1
0
void Screen::drawLogo(int x, int y, int logo, int colour, bool mini)
{
    if (data_logo_ == NULL) {
        data_logo_ = File::loadOriginalFile("mlogos.dat", size_logo_);
        data_logo_copy_ = new uint8[size_logo_];
    }
    if (data_mini_logo_ == NULL) {
        data_mini_logo_ = File::loadOriginalFile("mminlogo.dat", size_mini_logo_);
        data_mini_logo_copy_ = new uint8[size_mini_logo_];
    }

    for (int i = 0; i < size_logo_; i++)
        if (data_logo_[i] == 0xFE)
            data_logo_copy_[i] = colour;
        else
            data_logo_copy_[i] = data_logo_[i];
    for (int i = 0; i < size_mini_logo_; i++)
        if (data_mini_logo_[i] == 0xFE)
            data_mini_logo_copy_[i] = colour;
        else
            data_mini_logo_copy_[i] = data_mini_logo_[i];
    if (mini)
        scale2x(x, y, 16, 16, data_mini_logo_copy_ + logo * 16 * 16, 16);
    else
        scale2x(x, y, 32, 32, data_logo_copy_ + logo * 32 * 32, 32);

    dirty_ = true;
}
Beispiel #2
0
static void scale4x ( unsigned int* inputBuffer, unsigned int* outputBuffer, int inWidth, int inHeight, int seamlessWidth, int seamlessHeight )
{
  unsigned int * buffer2x = malloc((2 * inWidth) * (2 * inHeight) * sizeof(unsigned int));
  scale2x (inputBuffer, buffer2x, inWidth, inHeight, seamlessWidth, seamlessHeight);
  scale2x (buffer2x, outputBuffer, 2 * inWidth, 2 * inHeight, seamlessWidth, seamlessHeight);
  free(buffer2x);
}
Beispiel #3
0
void MinigameBbAnt::drawMagnifyingGlass(DrawList &drawList) {	
	scale2x(_objects[0].x - 28, _objects[0].y - 27);
	drawList.clear();
	drawList.add(_objects[0].anim->frameIndices[0], _objects[0].x, _objects[0].y, _objects[0].priority);
	drawList.add(_objects[0].anim->frameIndices[1], _objects[0].x, _objects[0].y, _objects[0].priority);
	drawList.add(_objects[0].anim->frameIndices[2], _objects[0].x, _objects[0].y, _objects[0].priority);
}
Beispiel #4
0
/**
 * Apply the Scale effect on a bitmap.
 * This function is simply a common interface for ::scale2x(), ::scale3x() and ::scale4x().
 * \param scale Scale factor. 2, 3 or 4.
 * \param void_dst Pointer at the first pixel of the destination bitmap.
 * \param dst_slice Size in bytes of a destination bitmap row.
 * \param void_src Pointer at the first pixel of the source bitmap.
 * \param src_slice Size in bytes of a source bitmap row.
 * \param pixel Bytes per pixel of the source and destination bitmap.
 * \param width Horizontal size in pixels of the source bitmap.
 * \param height Vertical size in pixels of the source bitmap.
 */
void scale(unsigned scale, void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
{
	switch (scale) {
	case 2 : scale2x(void_dst, dst_slice, void_src, src_slice, pixel, width, height); break;
	case 3 : scale3x(void_dst, dst_slice, void_src, src_slice, pixel, width, height); break;
	case 4 : scale4x(void_dst, dst_slice, void_src, src_slice, pixel, width, height); break;
	}
}
void MDP_FNCALL mdp_render_scale2x_cpp(MDP_Render_Info_t *renderInfo)
{
	if (!renderInfo)
		return;

	const unsigned int bytespp = (renderInfo->bpp == 15 ? 2 : renderInfo->bpp / 8);
	
#if defined(__GNUC__) && defined(__i386__)
	if (renderInfo->cpuFlags & MDP_CPUFLAG_MMX)
	{
		scale2x_mmx(renderInfo->destScreen, renderInfo->destPitch,
			    renderInfo->mdScreen, renderInfo->srcPitch,
			    bytespp, renderInfo->width, renderInfo->height);
	}
	else
#endif /* defined(__GNUC__) && defined(__i386__) */
	{
		scale2x(renderInfo->destScreen, renderInfo->destPitch,
			renderInfo->mdScreen, renderInfo->srcPitch,
			bytespp, renderInfo->width, renderInfo->height);
	}
}
Beispiel #6
0
/**
 * Apply the Scale effect on a bitmap.
 * This function is simply a common interface for ::scale2x(), ::scale3x() and ::scale4x().
 * \param scale Scale factor. 2, 203 (fox 2x3), 204 (for 2x4), 3 or 4.
 * \param void_dst Pointer at the first pixel of the destination bitmap.
 * \param dst_slice Size in bytes of a destination bitmap row.
 * \param void_src Pointer at the first pixel of the source bitmap.
 * \param src_slice Size in bytes of a source bitmap row.
 * \param pixel Bytes per pixel of the source and destination bitmap.
 * \param width Horizontal size in pixels of the source bitmap.
 * \param height Vertical size in pixels of the source bitmap.
 */
void scale(unsigned scale, void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned width, unsigned height)
{
	switch (scale) {
	case 202 :
	case 2 :
		scale2x(void_dst, dst_slice, void_src, src_slice, width, height);
		break;
	case 203 :
		scale2x3(void_dst, dst_slice, void_src, src_slice, 4, width, height);
		break;
	case 204 :
		scale2x4(void_dst, dst_slice, void_src, src_slice, 4, width, height);
		break;
	case 303 :
	case 3 :
		scale3x(void_dst, dst_slice, void_src, src_slice, width, height);
		break;
	case 404 :
	case 4 :
		scale4x(void_dst, dst_slice, void_src, src_slice, width, height);
		break;
	}
}
Beispiel #7
0
void gr_unlock_screen()
{
    if ( !screen_locked || !screen->pixels ) return ;

    screen_locked = 0 ;

    if ( scale_resolution != -1 )
    {
        uint8_t  * src8  = screen->pixels, * dst8  = scale_screen->pixels , * pdst = scale_screen->pixels ;
        uint16_t * src16 = screen->pixels, * dst16 = scale_screen->pixels ;
        uint32_t * src32 = screen->pixels, * dst32 = scale_screen->pixels ;
        int h, w;

        switch ( scale_screen->format->BitsPerPixel )
        {
            case    8:
                    if ( scale_resolution_orientation == 1 || scale_resolution_orientation == 3 )
                    {
                        if ( scale_resolution_aspectratio )
                        {
                            for ( w = 0; w < scale_screen->w; w++ )
                            {
                                if ( scale_resolution_table_w[w] != -1 )
                                {
                                    src8 = screen->pixels + scale_resolution_table_w[w];
                                    for ( h = scale_screen->h - 1; h-- ; )
                                    {
                                        if ( scale_resolution_table_h[h] != -1 ) *dst8 = src8[scale_resolution_table_h[h]];
                                        dst8 += scale_screen->pitch ;
                                    }
                                }
                                dst8 = pdst += scale_screen->format->BytesPerPixel ;
                            }
                        }
                        else
                        {
                            for ( w = 0; w < scale_screen->w; w++ )
                            {
                                src8 = screen->pixels + scale_resolution_table_w[w];
                                for ( h = scale_screen->h - 1; h-- ; )
                                {
                                    *dst8 = src8[scale_resolution_table_h[h]];
                                    dst8 += scale_screen->pitch ;
                                }
                            }
                            dst8 = pdst += scale_screen->format->BytesPerPixel ;
                        }
                    }
                    else
                    {
                        if ( scale_resolution_aspectratio )
                        {
                            for ( h = 0; h < scale_screen->h; h++ )
                            {
                                if ( scale_resolution_table_h[h] != -1 )
                                {
                                    src8 = screen->pixels + scale_resolution_table_h[h];
                                    for ( w = 0; w < scale_screen->w; w++ )
                                    {
                                        if ( scale_resolution_table_w[w] != -1 ) *dst8 = src8[scale_resolution_table_w[w]];
                                        dst8++;
                                    }
                                }
                                dst8 = pdst += scale_screen->pitch ;
                            }
                        }
                        else
                        {
                            for ( h = 0; h < scale_screen->h; h++ )
                            {
                                src8 = screen->pixels + scale_resolution_table_h[h];
                                for ( w = 0; w < scale_screen->w; w++ )
                                {
                                    *dst8 = src8[scale_resolution_table_w[w]];
                                    dst8++;
                                }
                                dst8 = pdst += scale_screen->pitch ;
                            }
                        }
                    }
                    break;

            case    16:
                    if ( scale_resolution_orientation == 1 || scale_resolution_orientation == 3 )
                    {
                        if ( scale_resolution_aspectratio )
                        {
                            int inc = scale_screen->pitch / scale_screen->format->BytesPerPixel;
                            for ( w = 0; w < scale_screen->w; w++ )
                            {
                                if ( scale_resolution_table_w[w] != -1 )
                                {
                                    src16 = screen->pixels + scale_resolution_table_w[w];
                                    for ( h = scale_screen->h - 1; h-- ; )
                                    {
                                        if ( scale_resolution_table_h[h] != -1 ) *dst16 = src16[scale_resolution_table_h[h]];
                                        dst16 += inc;
                                    }
                                }
                                dst16 = ( uint16_t * ) ( pdst += scale_screen->format->BytesPerPixel ) ;
                            }
                        }
                        else
                        {
                            int inc = scale_screen->pitch / scale_screen->format->BytesPerPixel;
                            for ( w = 0; w < scale_screen->w; w++ )
                            {
                                src16 = screen->pixels + scale_resolution_table_w[w];
                                for ( h = scale_screen->h - 1; h-- ; )
                                {
                                    *dst16 = src16[scale_resolution_table_h[h]];
                                    dst16 += inc;
                                }
                                dst16 = ( uint16_t * ) ( pdst += scale_screen->format->BytesPerPixel ) ;
                            }
                        }
                    }
                    else
                    {
                        if ( scale_resolution_aspectratio )
                        {
                            for ( h = 0; h < scale_screen->h; h++ )
                            {
                                if ( scale_resolution_table_h[h] != -1 )
                                {
                                    src16 = screen->pixels + scale_resolution_table_h[h];
                                    for ( w = 0; w < scale_screen->w; w++ )
                                    {
                                        if ( scale_resolution_table_w[w] != -1 ) *dst16 = src16[scale_resolution_table_w[w]];
                                        dst16++;
                                    }
                                }
                                dst16 = ( uint16_t * ) ( pdst += scale_screen->pitch ) ;
                            }
                        }
                        else
                        {
                            for ( h = 0; h < scale_screen->h; h++ )
                            {
                                src16 = screen->pixels + scale_resolution_table_h[h];
                                for ( w = 0; w < scale_screen->w; w++ )
                                {
                                    *dst16 = src16[scale_resolution_table_w[w]];
                                    dst16++;
                                }
                                dst16 = ( uint16_t * ) ( pdst += scale_screen->pitch ) ;
                            }
                        }
                    }
                    break;

            case    32:
                    if ( scale_resolution_orientation == 1 || scale_resolution_orientation == 3 )
                    {
                        if ( scale_resolution_aspectratio )
                        {
                            int inc = scale_screen->pitch / scale_screen->format->BytesPerPixel;
                            for ( w = 0; w < scale_screen->w; w++ )
                            {
                                if ( scale_resolution_table_w[w] != -1 )
                                {
                                    src32 = screen->pixels + scale_resolution_table_w[w];
                                    for ( h = scale_screen->h - 1; h-- ; )
                                    {
                                        if ( scale_resolution_table_h[h] != -1 ) *dst32 = src32[scale_resolution_table_h[h]];
                                        dst32 += inc;
                                    }
                                }
                                dst32 = ( uint32_t * ) ( pdst += scale_screen->format->BytesPerPixel ) ;
                            }
                        }
                        else
                        {
                            int inc = scale_screen->pitch / scale_screen->format->BytesPerPixel;
                            for ( w = 0; w < scale_screen->w; w++ )
                            {
                                src32 = screen->pixels + scale_resolution_table_w[w];
                                for ( h = scale_screen->h - 1; h-- ; )
                                {
                                    *dst32 = src32[scale_resolution_table_h[h]];
                                    dst32 += inc;
                                }
                                dst32 = ( uint32_t * ) ( pdst += scale_screen->format->BytesPerPixel ) ;
                            }
                        }
                    }
                    else
                    {
                        if ( scale_resolution_aspectratio )
                        {
                            for ( h = 0; h < scale_screen->h; h++ )
                            {
                                if ( scale_resolution_table_h[h] != -1 )
                                {
                                    src32 = screen->pixels + scale_resolution_table_h[h];
                                    for ( w = 0; w < scale_screen->w; w++ )
                                    {
                                        if ( scale_resolution_table_w[w] != -1 ) *dst32 = src32[scale_resolution_table_w[w]];
                                        dst32++;
                                    }
                                }
                                dst32 = ( uint32_t * ) ( pdst += scale_screen->pitch ) ;
                            }
                        }
                        else
                        {
                            for ( h = 0; h < scale_screen->h; h++ )
                            {
                                src32 = screen->pixels + scale_resolution_table_h[h];
                                for ( w = 0; w < scale_screen->w; w++ )
                                {
                                    *dst32 = src32[scale_resolution_table_w[w]];
                                    dst32++;
                                }
                                dst32 = ( uint32_t * ) ( pdst += scale_screen->pitch ) ;
                            }
                        }
                    }
                    break;
        }

        if ( SDL_MUSTLOCK( scale_screen ) ) SDL_UnlockSurface( scale_screen ) ;
        if ( waitvsync ) gr_wait_vsync();
        SDL_Flip( scale_screen ) ;
    }
    else if ( enable_scale )
    {
        GRAPH * scr;

        if ( scrbitmap->format->depth == 8 )
        {
            uint8_t * original, * poriginal;
            uint16_t * extra, * pextra;
            int n = scrbitmap->height, length;

            if (
                !scrbitmap_extra ||
                scrbitmap_extra->width != scrbitmap->width ||
                scrbitmap_extra->height != scrbitmap->height
            )
            {
                if ( scrbitmap_extra ) bitmap_destroy( scrbitmap_extra );
                scrbitmap_extra = bitmap_new( 0, scrbitmap->width, scrbitmap->height, 16 );
            }

            poriginal = scrbitmap->data;
            pextra = scrbitmap_extra->data;

            while ( n-- )
            {
                original = poriginal;
                extra = pextra;
                length = scrbitmap->width;
                while ( length-- ) *extra++ = sys_pixel_format->palette->colorequiv[ *original++ ];
                poriginal += scrbitmap->pitch;
                pextra = ( uint16_t * )((( uint8_t * ) pextra ) + scrbitmap_extra->pitch );
            }

            scr = scrbitmap_extra;
        }
        else
        {
            scr = scrbitmap;
        }

        /* Esto podria ir en un modulo aparte */
        switch ( scale_mode )
        {
            case SCALE_SCALE2X:
                scale2x( scr->data, scr->pitch, screen->pixels, screen->pitch, scr->width, scr->height );
                break;

            case SCALE_HQ2X:
                hq2x( scr->data, scr->pitch, screen->pixels, screen->pitch, scr->width, scr->height );
                break;

            case SCALE_SCANLINE2X:
                scanline2x( scr->data, scr->pitch, screen->pixels, screen->pitch, scr->width, scr->height );
                break;

            case SCALE_NOFILTER:
                scale_normal2x( scr->data, scr->pitch, screen->pixels, screen->pitch, scr->width, scr->height );
                break;

            case SCALE_NONE:
                // No usado
                break;
        }

        if ( SDL_MUSTLOCK( screen ) ) SDL_UnlockSurface( screen ) ;
        if ( waitvsync ) gr_wait_vsync();
        SDL_Flip( screen ) ;
    }
    else if ( scrbitmap->info_flags & GI_EXTERNAL_DATA )
    {
        if ( double_buffer ||
                (
                    updaterects_count == 1 &&
                    updaterects[0].x == 0 &&
                    updaterects[0].y == 0 &&
                    updaterects[0].x2 == scr_width - 1 &&
                    updaterects[0].y2 == scr_height - 1
                )
           )
        {
            if ( SDL_MUSTLOCK( screen ) ) SDL_UnlockSurface( screen ) ;
            if ( waitvsync ) gr_wait_vsync();
            SDL_Flip( screen ) ;
        }
        else
        {
            if ( updaterects_count )
            {
                int i;

                for ( i = 0 ; i < updaterects_count ; i++ )
                {
                    rects[ i ].x = updaterects[ i ].x;
                    rects[ i ].y = updaterects[ i ].y;
                    rects[ i ].w = ( updaterects[ i ].x2 - rects[ i ].x + 1 );
                    rects[ i ].h = ( updaterects[ i ].y2 - rects[ i ].y + 1 );
                }
                if ( SDL_MUSTLOCK( screen ) ) SDL_UnlockSurface( screen ) ;
                if ( waitvsync ) gr_wait_vsync();
                SDL_UpdateRects( screen, updaterects_count, rects ) ;
            }
        }
    }
}
Beispiel #8
0
void drawPNG() {
    double h = gHeight;
    double w = gWidth;

    glClearColor(0.0, 0.0, 0.0, 0.0);

    double max;
    if (gHeight > gWidth) {
        max = gHeight;
    } else {
        max = gWidth;
    }

    /*
     * This is for pressing the key '1'. It renders the png image as it is.
     * It can be blown up to whatever size the user desires, and the pixels/pixel 
     * size will be scaled accordingly with no algorithm attempted to depixel the
     * png image.
     *
     */
    if (gDrawMode == 1) {
        glClearColor(0.0, 0.0, 0.0, 0.0);
        double pointSize = int(yRes/h) + 1.0;

        glPointSize(pointSize);
        glBegin(GL_POINTS);
        glVertex3f(0.95,-0.95,0);

        for(int y=0; y<h; y++) {
            for (int x = 0; x < gWidth; x ++) {
                int index = 4 * x + (4 * w * y);

                glColor4d(int(gData[index]) / 256.0, int(gData[index+1]) / 256.0, int(gData[index+2]) / 256.0, int(gData[index+3]) / 256.0) ;
                glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max, -1 + (pointSize / yRes)+ 2*y/max, 0);
            }
        }
        glEnd();
    }
    
    /*
     * This is for pressing the key '2'. It renders the png image using the EPX algorithm. Basically, 
     * we break down each pixel into a 2x2 (so 4 pixels). If two same-color pixels of the original 
     * png image are adjacent to a pixel of the original png image such that the three pixels form 
     * a 90 degree angle, then the corresponding pixel in the blown up 2x2 is that color as well. So,
     * for example, let's say that pixel A and pixel B are the same color white such that pixel A 
     * is adjacently above pixel C and pixel B is adjacently to the right of pixel C. We then blow up
     * pixel C into a 2x2 set of pixels. Since pixels A and B are above and right of pixel C, we would 
     * then render the top right pixel of the 2x2 with the same color, white. This is essentially the 
     * EPX algorithm.
     *
     */ 

    else if (gDrawMode == 2) {
        glClearColor(0.0, 0.0, 0.0, 0.0);
        double pointSize = round(0.5 * yRes/h + 0.5);

        glPointSize(pointSize);
        glBegin(GL_POINTS);
        glVertex3f(0.95,-0.95,0);

        for(int y=0; y<h; y++) {
            for (int x = 0; x < gWidth; x ++) {
                int index = 4 * x + (4 * w * y);

                glColor4d(int(gData[index]) / 256.0, int(gData[index+1]) / 256.0, int(gData[index+2]) / 256.0, int(gData[index+3]) / 256.0) ;

                int upIndex = getUpNeighbor(x,y, gWidth, gHeight);
                int downIndex = getDownNeighbor(x,y, gWidth, gHeight);
                int leftIndex = getLeftNeighbor(x,y, gWidth, gHeight);
                int rightIndex = getRightNeighbor(x,y, gWidth, gHeight);

                // this is for the corner cases
                if ((upIndex == -1 && leftIndex == -1) ||
                    (upIndex == -1 && rightIndex == -1) ||
                    (downIndex == -1 && leftIndex == -1) ||
                    (downIndex == -1 && rightIndex == -1))
                {
                    // bottom-left pixel of the 2x2
                    glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max, -1 + (pointSize / yRes)+ 2*y/max, 0);
                    // bottom-right pixel of the 2x2
                    glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max + 2*pointSize/xRes, -1 + (pointSize / yRes)+ 2*y/max , 0);
                    // top-left pixel of the 2x2
                    glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max, -1 + (pointSize / yRes)+ 2*y/max + 2*pointSize/yRes, 0);
                    // top-right pixel of the 2x2
                    glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max + 2*pointSize/xRes, -1 + (pointSize / yRes)+ 2*y/max + 2*pointSize/yRes, 0);                    
                }
                
                else
                {
                    Vec3 up, down, left, right;
                    up.x = gData[upIndex];
                    up.y = gData[upIndex+1];
                    up.z = gData[upIndex+2];
                    down.x = gData[downIndex];
                    down.y = gData[downIndex+1];
                    down.z = gData[downIndex+2];
                    right.x = gData[rightIndex];
                    right.y = gData[rightIndex+1];
                    right.z = gData[rightIndex+2];
                    left.x = gData[leftIndex];
                    left.y = gData[leftIndex+1];
                    left.z = gData[leftIndex+2];

                    bool upLeft = (up == left);
                    bool upRight = (up == right);
                    bool downLeft = (down == left);
                    bool downRight = (down == right);
                    //std::cout << upLeft << std::endl;
                    //std::cout << upRight << std::endl;
                    //std::cout << downLeft << std::endl;
                    //std::cout << downRight << std::endl;

                    if (downLeft) {
                        glColor4d(down.x / 256.0, down.y / 256.0, down.z / 256.0, int(gData[downIndex+3]) / 256.0);
                    } 
                    // bottom-left pixel of the 2x2
                    glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max, -1 + (pointSize / yRes)+ 2*y/max, 0);
                    glColor4d(int(gData[index]) / 256.0, int(gData[index+1]) / 256.0, int(gData[index+2]) / 256.0, int(gData[index+3]) / 256.0);

                    if (downRight) {
                        glColor4d(down.x / 256.0, down.y / 256.0, down.z / 256.0, int(gData[downIndex+3]) / 256.0);
                    } 
                    // bottom-right pixel of the 2x2
                    glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max + 2*pointSize/xRes, -1 + (pointSize / yRes)+ 2*y/max , 0);
                    glColor4d(int(gData[index]) / 256.0, int(gData[index+1]) / 256.0, int(gData[index+2]) / 256.0, int(gData[index+3]) / 256.0);

                    if (upLeft) {
                        glColor4d(up.x / 256.0, up.y / 256.0, up.z / 256.0, int(gData[upIndex+3]) / 256.0);
                    }
                    // top-left pixel of the 2x2
                    glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max, -1 + (pointSize / yRes)+ 2*y/max + 2*pointSize/yRes, 0);
                    glColor4d(int(gData[index]) / 256.0, int(gData[index+1]) / 256.0, int(gData[index+2]) / 256.0, int(gData[index+3]) / 256.0);

                    if (upRight) {
                        glColor4d(up.x / 256.0, up.y / 256.0, up.z / 256.0, int(gData[downIndex+3]) / 256.0);
                    }
                    // top-right pixel of the 2x2
                    glVertex3f(-1 + (pointSize / xRes) + 2*(x)/max + 2*pointSize/xRes, -1 + (pointSize / yRes)+ 2*y/max + 2*pointSize/yRes, 0);
                    glColor4d(int(gData[index]) / 256.0, int(gData[index+1]) / 256.0, int(gData[index+2]) / 256.0, int(gData[index+3]) / 256.0);
                }
            }
        }
        glEnd();
    }

    // glDrawPixels, no EPX, just regular image
    else if (gDrawMode == 3) {
        glClearColor(0.0, 0.0, 0.0, 0.0);
        glColor3f(0.0f, 0.0f, 0.0f);
        //GLubyte color[2][2][4];

        
        GLubyte color[gHeight][gWidth][4];
        for(int y = 0; y < gHeight; y++) {
            for (int x = 0; x < gWidth; x ++) {
                int index = 4 * x + (4 * w * y);

                color[y][x][0] = int(gData[index]);
                color[y][x][1] = int(gData[index+1]);
                color[y][x][2] = int(gData[index+2]);
                color[y][x][3] = int(gData[index+3]);

                //std::cout << "X: " << x/3 << " Y: " << y << "  rgb: " << int(gData[index]) << " " << int(gData[index + 1]) << " " << int(gData[index+2]) << std::endl;

                //glColor3d(int(gData[index]) / 256.0, int(gData[index+1]) / 256.0, int(gData[index+2]) / 256.0);
                //glVertex3f(-1 + (pointSize / xRes) + 2*(x/3)/max, -1 + (pointSize / yRes)+ 2*y/max, 0);
            }
        }
        
        //GLfloat scaleX = 1.0f * xRes / 2;
        //GLfloat scaleY = 1.0f * yRes / 2;
        //std::cout << scaleX << " " << scaleY << std::endl;
        //glPixelZoom(scaleX/15.99, scaleY/15.99);
        glPixelZoom(floor(xRes/max), floor(yRes/max));

        //glPixelZoom(5,5);
        glRasterPos2d(-1.0, -1.0);
        glClear(GL_COLOR_BUFFER_BIT);
        glDrawPixels( gWidth, gHeight, GL_RGBA, GL_UNSIGNED_BYTE, color );
        glFlush();
    }

    /* EPX algorithm with gldrawPixels */
    else if (gDrawMode == 4) {
        epx(gHeight, gWidth, h, w, xRes, yRes, max, gData);
    }

    /* scale2x algorithm with gldrawPixels */
    else if (gDrawMode == 5) {
        scale2x(gHeight, gWidth, h, w, xRes, yRes, max, gData);
    }
    /* scale3x algorithm with gldrawPixels */
    else if (gDrawMode == 6) {
        scale3x(gHeight, gWidth, h, w, xRes, yRes, max, gData);
    }

    /* scale4x algorithm with gldrawPixels */
    else if (gDrawMode == 7) {
        scale4x(gHeight, gWidth, h, w, xRes, yRes, max, gData);
    }

    /* eagle algorithm with gldrawPixels */
    else if (gDrawMode == 8) {
        eagle(gHeight, gWidth, h, w, xRes, yRes, max, gData);
    }

    /* bilinear interpolation! */
    else if (gDrawMode == 9) {
        bilinear2x(gHeight, gWidth, h, w, xRes, yRes, max, gData);
    }

    /* bicubic interpolation! */
    else if (gDrawMode == 10) {
        bicubic2x(gHeight, gWidth, h, w, xRes, yRes, max, gData);
    }

     /* eagle3x! */
    else if (gDrawMode == 11) {
        eagle3x(gHeight, gWidth, h, w, xRes, yRes, max, gData);
    }

    // no matter what draw mode, draw nearest neighbor on the right side
    // Set matrix mode
    glMatrixMode(GL_PROJECTION);
    // push current projection matrix on the matrix stack
    glPushMatrix();
    // Set an ortho projection based on window size
    glLoadIdentity();
    glOrtho(0, xRes * 2, 0, yRes, 0, 1);
    // Switch back to model-view matrix
    glMatrixMode(GL_MODELVIEW);
    // Store current model-view matrix on the stack
    glPushMatrix();
    // Clear the model-view matrix
    glLoadIdentity();
    // You can specify this in window coordinates now
    glRasterPos2i(2*xRes,0);
    glPixelZoom(floor(xRes/max), floor(yRes/max));
    glDrawPixels(gWidth, gHeight, GL_RGBA, GL_UNSIGNED_BYTE, gData);
    // Restore the model-view matrix
    glPopMatrix();
    // Switch to projection matrix and restore it
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();

}