aristidis_pap Δημοσ. 9 Φεβρουαρίου 2010 Δημοσ. 9 Φεβρουαρίου 2010 καλησπερα.με αυτο το προγραμμα σε builder 6 #include <vcl.h> #pragma hdrstop #pragma argsused int main(int argc, char* argv[]) { TJPEGImage *jp = new TJPEGImage(); delete jp; return 0; } παιρνω μην. undefined symbol TJPEGImage. μπορει να βοηθησει κανεις
aristidis_pap Δημοσ. 9 Φεβρουαρίου 2010 Μέλος Δημοσ. 9 Φεβρουαρίου 2010 δοκίμασε αυτό #include <jpeg.hpp> παιρνω μην. [Linker Fatal Error] Fatal: Unable to open file 'GRAPHICS.OBJ' ---------- Προσθήκη στις 01:17 ---------- Προηγούμενο μήνυμα στις 01:06 ---------- παιρνω μην.[Linker Fatal Error] Fatal: Unable to open file 'GRAPHICS.OBJ' εβαλα run time libraries και ετρεξε.ευχαριστω.μπορεις να βοηθησεις στο προηγουμενο ερωτημα μου σχετικα με φορτωμα jpeg αρχεια σε texture?
Directx Δημοσ. 9 Φεβρουαρίου 2010 Δημοσ. 9 Φεβρουαρίου 2010 Όταν λες texture τι εννοείς; Θέλεις το JPEG σου να χρησιμοποιηθεί ως Brush για το γέμισμα κάποιου σχήματος για παράδειγμα; Αν ναι τότε ο παρακάτω κώδικας φορτώνει μια εικόνα JPEG (ptrJPG) την οποία μετατρέπει σε Bitmap (ptrBMP) ώστε να την αναθέσει ως Brush->Bitmap texture στο Brush του PaintBox1 component (υποθέτω ότι υπάρχει ένα TPaintBox στην φόρμα) στο οποίο ζωγραφίζει μια Ellipse με την Brush/Image αυτή. > // Load JPEG Image TJPEGImage *ptrJPG = NULL; Graphics::TBitmap *ptrBMP = NULL; try { /* Load JPEG to ptrJPG. */ ptrJPG = new TJPEGImage(); ptrJPG->LoadFromFile("D:\\JPEG.JPG"); /* Convert ptrJPG to Bitmap. */ ptrBMP = new Graphics::TBitmap(); ptrBMP->Width = ptrJPG->Width; ptrBMP->Height= ptrJPG->Height; ptrBMP->Canvas->Draw(0, 0, ptrJPG); /* Derive brush from Bitmap. */ PaintBox1->Canvas->Brush->Bitmap = ptrBMP; PaintBox1->Canvas->Ellipse(PaintBox1->ClientRect); } __finally { /* Clear! */ delete ptrBMP; delete ptrJPG; } Η έξοδος που δίνει ο κώδικας είναι: Σε κάθε περίπτωση πάντως, οι ρουτίνες γραφικών του C++ Builder 6 λειτουργούν με Bitmap οπότε η μετατροπή του JPEG είναι συνήθως απαραίτητη. Καλή συνέχεια!! Υ.Γ. Αν θυμάμαι καλά ( ; ; ) προ των Windows '98 το μέγεθος ενός Brush texture περιοριζόταν στα 8x8 pixels (το καταθέτω απλά για ιστορικούς λόγους).
aristidis_pap Δημοσ. 9 Φεβρουαρίου 2010 Μέλος Δημοσ. 9 Φεβρουαρίου 2010 Όταν λες texture τι εννοείς; Θέλεις το JPEG σου να χρησιμοποιηθεί ως Brush για το γέμισμα κάποιου σχήματος για παράδειγμα; Αν ναι τότε ο παρακάτω κώδικας φορτώνει μια εικόνα JPEG (ptrJPG) την οποία μετατρέπει σε Bitmap (ptrBMP) ώστε να την αναθέσει ως Brush->Bitmap texture στο Brush του PaintBox1 component (υποθέτω ότι υπάρχει ένα TPaintBox στην φόρμα) στο οποίο ζωγραφίζει μια Ellipse με την Brush/Image αυτή. > // Load JPEG Image TJPEGImage *ptrJPG = NULL; Graphics::TBitmap *ptrBMP = NULL; try { /* Load JPEG to ptrJPG. */ ptrJPG = new TJPEGImage(); ptrJPG->LoadFromFile("D:\\JPEG.JPG"); /* Convert ptrJPG to Bitmap. */ ptrBMP = new Graphics::TBitmap(); ptrBMP->Width = ptrJPG->Width; ptrBMP->Height= ptrJPG->Height; ptrBMP->Canvas->Draw(0, 0, ptrJPG); /* Derive brush from Bitmap. */ PaintBox1->Canvas->Brush->Bitmap = ptrBMP; PaintBox1->Canvas->Ellipse(PaintBox1->ClientRect); } __finally { /* Clear! */ delete ptrBMP; delete ptrJPG; } Η έξοδος που δίνει ο κώδικας είναι: Σε κάθε περίπτωση πάντως, οι ρουτίνες γραφικών του C++ Builder 6 λειτουργούν με Bitmap οπότε η μετατροπή του JPEG είναι συνήθως απαραίτητη. Καλή συνέχεια!! Υ.Γ. Αν θυμάμαι καλά ( ; ; ) προ των Windows '98 το μέγεθος ενός Brush texture περιοριζόταν στα 8x8 pixels (το καταθέτω απλά για ιστορικούς λόγους). ευχαριστω για τη βοηθεια.εξηγω λιγο την εφαρμογη.σε ενα οποιοδηποτε παιχνιδι τα γραφικα (χαρακτηρες και τοποι δρασης) σχεδιαζονται με πολυγωνα (ειδικα προγραμματα οπως milkshape ,3ds max) και ακολουθως αυτα γεμιζουν με την αντιστοιχη εικονα απο bmp,tga or jpeg files.για παραδειγμα παραθετω 2 εικονες http://pragmaticideas.files.wordpress.com/2008/12/max2.jpg Ο κωδικας για παραδειγμα που φορτωνει μια εικονα bmp |o builder 6 με opengl βιβλιοθηκη γραφικων ειναι #ifndef _IMAGE_H #define _IMAGE_H #include "jpeglib.h" // These defines are used to tell us about the type of TARGA file it is #define TGA_RGB 2 // This tells us it's a normal RGB (really BGR) file #define TGA_A 3 // This tells us it's a ALPHA file #define TGA_RLE 10 // This tells us that the targa is Run-Length Encoded (RLE) // This is our image structure for our targa data struct tImage { int channels; // The channels in the image (3 = RGB : 4 = RGBA) int sizeX; // The width of the image in pixels int sizeY; // The height of the image in pixels unsigned char *data; // The image pixel data }; // This loads and returns the BMP data //tImage *LoadBMP(const char *strFileName); // This loads and returns the TGA data tImage *LoadTGA(const char *strFileName); // This loads and returns the JGP data tImage *LoadJPG(const char *strFileName); // This decompresses the JPEG and fills in the image data //void DecodeJPG(jpeg_decompress_struct* cinfo, tImage *pImageData); #endif #include "image.h" ///////////////////////////////// LOAD BMP \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\* ///// ///// This loads the BMP file and returns it's data in a tImage struct ///// ///////////////////////////////// LOAD BMP \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\* /* tImage *LoadBMP(const char *strFileName) { AUX_RGBImageRec *pBitmap = NULL; FILE *pFile = NULL; // Open a file pointer to the BMP file and check if it was found and opened if((pFile = fopen(strFileName, "rb")) == NULL) { // Display an error message saying the file was not found, then return NULL MessageBox(g_hWnd, "Unable to load BMP File!", "Error", MB_OK); return NULL; } // Load the bitmap using the aux function stored in glaux.lib pBitmap = auxDIBImageLoad(strFileName); // Allocate the tImage tImage *pImage = (tImage *)malloc(sizeof(tImage)); // Assign the channels, width, height and image bits to pImage pImage->channels = 3; pImage->sizeX = pBitmap->sizeX; pImage->sizeY = pBitmap->sizeY; pImage->data = pBitmap->data; // Free the bitmap pointer (The "data" will be freed later in CreateTexture()) free(pBitmap); // Return our image data return pImage; } //--------------------------------------------------------------------------- GLuint LoadGLTexture(const char *filename) // Load Bitmaps And Convert To Textures { AUX_RGBImageRec *pImage; // Create Storage Space For The Texture GLuint texture = 0; // Texture ID pImage = LoadBMP(filename); // Loads The Bitmap Specified By filename // Load the bitmap, check for errors, if bitmap's not found quit if (pImage != NULL && pImage->data != NULL) // If Texture Image Exists { glGenTextures(1, &texture); // Create The Texture // Typical texture generation using data from the bitmap glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, 3, pImage->sizeX, pImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, pImage->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); free(pImage->data); // Free The Texture Image Memory free(pImage); // Free The Image Structure } return texture; // Return The Status } θα ηθελα λοιπον κατι αντιστοιχο για jpeg αρχειο.Δηλαδη ενα δεικτη σε struct tImage { int channels; // The channels in the image (3 = RGB : 4 = RGBA) int sizeX; // The width of the image in pixels int sizeY; // The height of the image in pixels unsigned char *data; // The image pixel data }; ωστε αντιστοιχα με την εντολη glTexImage2D(GL_TEXTURE_2D, 0, 3, pImage->sizeX, pImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, pImage->data); να γεμισω το τεχτθρε που χρειαζομαι. ο κωδικας που μου εστειλες δεινει τα sizeX=ptrBMP->Width = ptrJPG->Width; sizeY=ptrBMP->Height= ptrJPG->Height; αν ειχα και τα data μαλλον θα δουλεψει ευχαριστω για το ενδιαφερον
Προτεινόμενες αναρτήσεις
Αρχειοθετημένο
Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.