Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6769633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:13:00+00:00 2026-05-26T15:13:00+00:00

I am trying to scale an image without using the function gluScaleImage which is

  • 0

I am trying to scale an image without using the function gluScaleImage which is too long (and not achieving to include “glh” lib in my project (to use glhScaleImage)).
I read this advice:

If this is just about displaying images with various sizes, why not create a textured quad and
scale it to the requested size? The texture could always be the same size then.

And that is what I try to do with the following code :
the result is that I see well written “BACK” in red but don’t see “before glflush” and the background has a strange color (sometimes purple, sometimes green (concerning the green issue i suspect it to be a wrong initialization of the graphic card))
=> can anyone tell me what is wrong in my texturing of the buffer obtained with glReadPixels ?
=> or is there another solution ?
(I would prefer a correction of this code than another solution (framebuffer, …)).

// ---
glColor4ub(255,0,0,200);
myPrintingFunction(200,200,"before glFlush");   
glFlush();

// Unload Bytes
if (mBuffer != NULL)
{
    delete[] mBuffer;
    mBuffer = NULL;
}

// Load Bytes from current window
mBuffer = new GLubyte[ClientWidth * ClientHeight * 4];
glReadBuffer(GL_BACK);
glReadPixels(0, 0, ClientWidth, ClientHeight, GL_BGRA, GL_UNSIGNED_BYTE, mBuffer);

SwapBuffers(ghDC);    

// Unload TextureId
if (mTextureId != 0)
{
    glDeleteTextures(1, &mTextureId);
    mTextureId = 0;
}

// Load TextureId
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &mTextureId);
glBindTexture(GL_TEXTURE_2D, mTextureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, ClientWidth, ClientHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, mBuffer);

// ---
glViewport(-mBufferWidth, -mBufferHeight, mBufferWidth * 2, mBufferHeight * 2);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(double(-mBufferWidth), double(mBufferWidth), double(-mBufferHeight), double(mBufferHeight), 1000.0, 100000.0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glTranslatef(0.0, 0.0, -50000.0);

glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, mTextureId);
mxIncrust0 = 0.0;
myIncrust0 = 0.0;
mxIncrust1 = mBufferWidth;
myIncrust1 = mBufferHeight;
glBegin(GL_QUADS);
    glColor4ub((unsigned char)255,(unsigned char)255,(unsigned char)255,(unsigned char)255);
    glTexCoord2d(0.0, 0.0);
    glVertex2d(mxIncrust0, myIncrust0);
    glTexCoord2d(0.0, 1.0);
    glVertex2d(mxIncrust0, myIncrust1);
    glTexCoord2d(1.0,1.0);
    glVertex2d(mxIncrust1, myIncrust1);
    glTexCoord2d(1.0,0.0);
    glVertex2d(mxIncrust1, myIncrust0);
glEnd();

glDisable(GL_TEXTURE_2D);  

glColor4ub(255,0,0,200);
myPrintingFunction(100,100,"BACK");                                        

glFlush();

if (mBufferPlayout != NULL)
{
    delete[] mBufferPlayout;
    mBufferPlayout = NULL;
}
mBufferPlayout = new GLubyte [mBufferWidth * mBufferHeight * 4];

glReadBuffer(GL_BACK);
glReadPixels(0, 0, mBufferWidth, mBufferHeight, GL_BGRA, GL_UNSIGNED_BYTE, mBufferPlayout);

// then I pass this mBufferPlayout to a graphic card (capture card in output in fact)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:13:00+00:00Added an answer on May 26, 2026 at 3:13 pm

    Ok I found the error (with glGetError()) :
    GL_BGRA does not exist
    So I replaced it with GL_RGBA and I have my texture well bound to the quad
    (GL_RGBA8 does not work)
    I still have a greenish taint issue but this must be another problem : frame initialized with YUV ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to show a graph image which is horizontally long. The problem
I'm trying scale up an image in Flash without making it pixelated, I know
I'm trying to rotate and then scale an image using android.graphics.Matrix. The code is
I'm trying to scale down a Bitmap using GDI+ by doing the following: Bitmap
I am trying to display an image from a URL, which may be larger
I'm trying to have an image scale to a certain size depending on the
I'm trying to utilize the Image task in Ant, which requires Java Advanced Imaging.
I'm trying to create a spectral image with a constant grey-scale value for every
I'm trying to scale a tiny image (something like 20x40 pixels) to an arbitrarily
I'm trying to scale an image down, change the image, then scale it back

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.