473,701 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Image getting skewed

Hi guys,
I am writing a imaging aplication on VC++.I have to display images and
apply effects onto it.Images could be of any type like jpg,gif,bmp,psd ...M
uding createDibSectio n API.it requires BITMAPINFO struc as one of its
parameters.Its working well(Images are successfully displayed) but my
problem is that in certain images(of any type)they are skewed and becomes
B/W(means Data corruption).U can see my code of populating BITMAPINFO and
CreateDibSectio n...Can any body help me in solving the annoying probs.
[Note:If I am changing the dimension of image by few pixels using
photoshop it displays well]

BITMAPINFO bmi;

bmi.bmiHeader.b iSize = sizeof(BITMAPIN FOHEADER);
bmi.bmiHeader.b iBitCount = 24; bmi.bmiHeader.b iWidth
= swidth;//Image width
bmi.bmiHeader.b iHeight = -sheight;//Image Height //
neg for top-to-bottom
bmi.bmiHeader.b iPlanes = 1;
bmi.bmiHeader.b iCompression = BI_RGB; // uncompressed
bmi.bmiHeader.b iSizeImage = 0; // unused for BI_RGB
bmi.bmiHeader.b iXPelsPerMeter = 0;
bmi.bmiHeader.b iYPelsPerMeter = 0;
bmi.bmiHeader.b iClrUsed = 0;
bmi.bmiHeader.b iClrImportant = 0;
bmi.bmiColors[0].rgbBlue = 0;
bmi.bmiColors[0].rgbRed = 0;
bmi.bmiColors[0].rgbGreen = 0;
bmi.bmiColors[0].rgbReserved = 0;
hBmp = CreateDIBSectio n( hdc_
, &bmi
, DIB_RGB_COLORS
, &imageBuff //pointer to created buf
, NULL
, 0);

dcMem = ::CreateCompati bleDC(hdc_);//creates a memory compatible
device context (DC)passing exixting DC
(HBITMAP) ::SelectObject( dcMem, hBmp); //selects handle of image to
Device
//context dcMem

Jul 23 '05 #1
1 1627
"apoorv" <ar**********@n ospam.quark.com > wrote in message
news:93******** *************** *******@localho st.talkaboutpro gramming.com...
I am writing a imaging aplication on VC++.I have to display images and
apply effects onto it.Images could be of any type like jpg,gif,bmp,psd ...M
uding createDibSectio n API.it requires BITMAPINFO struc as one of its
parameters.Its working well(Images are successfully displayed) but my
problem is that in certain images(of any type)they are skewed and becomes
B/W(means Data corruption).U can see my code of populating BITMAPINFO and
CreateDibSectio n...Can any body help me in solving the annoying probs.

Most likely this is related to a padding issue: on many systems, the
data for each row of pixels needs to be aligned to an address that
is a multiple of 2 (or 4). If data for a pixel row has an odd size,
padding bytes need to be inserted.

But, ahem, what was your C++ question ?

--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
1197
by: Cameron Laird | last post by:
*DevSource* profiles "The State of the Scripting Universe" in <URL: http://www.devsource.com/article2/0,1759,1778141,00.asp >.
53
4948
by: Kerberos | last post by:
I followed Dan Cederholm's image replacement tutorial, to replace a header tag by a logo. The h1 is clickable if no CSS is applied but it I replace it by the logo, the area isn't clickable anymore when I pass the mouse over the logo. Is there a way to replace a link by an image that will still be clickable? Thanks, -- Kerberos.
13
4567
by: lkrubner | last post by:
Suppose I need to get an image as a stream of bytes. I want to store this in a variable and then embed it in some Postscript code. In my Postscript code, the image might look like this: {< ffffffffffffffffffffffffffffffffffffffffffffffffffff ff000000000000000000000000000000000000ffffffffffffff ff00efefefefefefefefefefefefefefefef0000ffffffffffff ff00efefefefefefefefefefefefefefefef00ce00ffffffffff
1
1213
by: apoorv | last post by:
Hi guys, I am writing a imaging aplication on VC++.I have to display images and apply effects onto it.Images could be of any type like jpg,gif,bmp,psd... I am using createDibSection API.it requires BITMAPINFO struc as one of its parameters.Its working well(Images are successfully displayed) but my problem is that in certain images(of any type)they are skewed and becomes B/W(means Data corruption).U can see my code of populating...
0
874
by: apoorv | last post by:
Hi guys, I am writing a imaging aplication on VC++.I have to display images and apply effects onto it.Images could be of any type like jpg,gif,bmp,psd... I am using createDibSection API.it requires BITMAPINFO struc as one of its parameters.Its working well(Images are successfully displayed) but my problem is that in certain images(of any type)they are skewed and becomes B/W(means Data corruption).U can see my code of populating...
3
63429
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and display (in the status bar) the image coordinates of the mouse location. However, if I use the picturebox's MouseMove event, I am getting the coordinates of the mouse over the PICTUREBOX, not the actual image underneath that (which is stretched)....
16
1948
by: Nicky | last post by:
I am using Visual C# 2005 and I need help creating a filter that will turn a picture black and white. This code I have so far is: byte red, green, blue, avg, newColor; int x; int y; ImageArray img = new ImageArray(pictureBoxMainImage.Image); img.LockImage();
1
1144
by: Praveen | last post by:
Hi, You guys know how secure sites usually use "skewed text" in images to let you manually verify registration, etc.? I would like to know if there is some control for asp.net that is available for this purpose (free or otherwise). Thanks Praveen
3
22498
by: Andrzej | last post by:
I have a picturebox on my C# .NET form. The picturebox size mode is set to zoom. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and display (in the status bar) the image coordinates of the mouse location. However, if I use the picturebox's MouseMove event, I am getting the coordinates of the mouse over the PICTUREBOX, not the actual image underneath that (which is zoomed). i.e....
0
8649
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9221
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9082
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4410
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4661
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3102
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2035
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.