Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
J

jgeorge21

@jgeorge21
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • archiving code or binary within my prog
    J jgeorge21

    Sure, if the code is run on an interpreter.

    C / C++ / MFC question data-structures

  • GDI+ Bitmaps
    J jgeorge21

    In my quest for a simple to use image loading library I came across GDI+. I only want to use the portion of GDI+ that loads images, since it loads every image type that I would ever need into a DIB (which I can extract and feed OpenGL). However, I have the most annoying and frustrating issue: the image is not loaded and the lastResult member of the Bitmap object indicates InvalidParameter. Obviously I'm feeding it something bad. The relevant code snippet follows: xBoolean xImage::Load (char *fileName, xBoolean mipmap) { BitmapData *bmpData = new BitmapData (); Rect *rect = new Rect (); sint32 format, stride; uint32 i, j; xbyte *tempBuffer; uint32 wideLen; WCHAR *fileNameW = NULL; if (fileName == NULL) // Early out if string is NULL return xfalse; // Convert C string to UNICODE wideLen = MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, fileName, -1, NULL, 0); // Get necessary length fileNameW = (WCHAR *)malloc (wideLen); // Alloc string MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, fileName, -1, fileNameW, wideLen); // Translate string Bitmap bmp ((const WCHAR *)fileNameW, FALSE); ... The string fileName is being properly translated to fileNameW as below: // Original String fileName[0] 119 'w' char fileName[1] 104 'h' char fileName[2] 105 'i' char fileName[3] 116 't' char fileName[4] 101 'e' char fileName[5] 46 '.' char fileName[6] 116 't' char fileName[7] 103 'g' char fileName[8] 97 'a' char fileName[9] 0 char // Wide String fileNameW[0] 119 unsigned short fileNameW[1] 104 unsigned short fileNameW[2] 105 unsigned short fileNameW[3] 116 unsigned short fileNameW[4] 101 unsigned short fileNameW[5] 46 unsigned short fileNameW[6] 116 unsigned short fileNameW[7] 103 unsigned short fileNameW[8] 97 unsigned short fileNameW[9] 0 unsigned short The constructor for the Bitmap object is as follows: class Bitmap : public Image { public: friend class Image; friend class CachedBitmap; Bitmap( IN const WCHAR *filename, IN BOOL useEmbeddedColorManagement = FALSE ); Recall that the lastResult member is being set to InvalidParameter. Here are the possible GDI+ return values: enum Status { Ok = 0, GenericError = 1, InvalidParameter = 2, OutOfMemory = 3, ObjectBusy = 4, InsufficientBuffer = 5, NotImplemented = 6, Win32Error = 7, WrongState = 8, Aborted = 9, FileNotF

    C / C++ / MFC graphics winforms game-dev help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups