CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17

Thread: Convert custom bitmap to CBitmap/CImage bits format

  1. #16
    Join Date
    Jan 2009

    Re: Convert custom bitmap to CBitmap/CImage bits format

    I am open to give any information that I got about this member variable, but this is only from source code, is the only information source. I come back little bit later.

  2. #17
    Join Date
    Jan 2009

    Re: Convert custom bitmap to CBitmap/CImage bits format

    @VictorN: you helped me a lot in the past and I thank you. Even if you have enough time to answer me or not, from respect to you I'll try to explain as much as I could of what is about this variable:

    The definition of this class is
    	class CCustomBitmap
    		std::vector<float> data;
    		int m_nWidth;
    		int m_nHeight;
    		int channels;
    			: m_nWidth(0),
    			channels(0) {}
    		CCustomBitmap(int m_nWidth, int m_nHeight, int channels)
    			: data(m_nWidth * m_nHeight * channels),
    			channels(channels) {}
    		const float& operator [](size_t i) const { return data[i]; }
    		float& operator [](size_t i) { return data[i]; }
    		int getChannels() const { return channels; }
    channels is declared here but seem not be involved into serializing method:
    	CCustomBitmap loadImage(const std::string& filename)
    		std::ifstream file(filename, std::ios::binary);
    		int C = 3;
    		int nHeight, nWidth;
    		file >> nWidth >> nHeight;
    		float scale;
    		file >> scale;			// I noticed that scale is -1
    		scale = fabs(scale);	        // so here scale is 1.0
    		CCustomBitmap image(nWidth, nHeight, C);
    		for (int h = 0; h < nHeight; ++h)
    			for (int w = 0; w < nWidth; ++w)
    				for (int c = 0; c < C; ++c)
    					float x;
    					file.read((char*)&x, sizeof(float));
    					image[((nHeight - 1 - h) * nWidth + w) * C + c] = x * scale;  // scale is 1, so image[((nHeight - 1 - h) * nWidth + w) * C + c] = x is enough here
    		return image;
    but CCustomBitmap:: data is populated on 3 dimension array somehow ... the problem is that I don't know how to populate this CCustomBitmap:: data which has 3 d array from CImage, which has a 2 dimension array GetPixel(w, h). I don't have any extra-information about that variable, channels.

    Because I am stuck here, any opinion/hint/solution will be very valuable !!! Thank you.
    Last edited by mesajflaviu; November 29th, 2019 at 05:17 AM.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)