473,503 Members | 2,322 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 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 BITMAPINFO and
CreateDibSection...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.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biBitCount = 24; bmi.bmiHeader.biWidth
= swidth;//Image width
bmi.bmiHeader.biHeight = -sheight;//Image Height //
neg for top-to-bottom
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB; // uncompressed
bmi.bmiHeader.biSizeImage = 0; // unused for BI_RGB
bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
bmi.bmiColors[0].rgbBlue = 0;
bmi.bmiColors[0].rgbRed = 0;
bmi.bmiColors[0].rgbGreen = 0;
bmi.bmiColors[0].rgbReserved = 0;
hBmp = CreateDIBSection( hdc_
, &bmi
, DIB_RGB_COLORS
, &imageBuff //pointer to created buf
, NULL
, 0);

dcMem = ::CreateCompatibleDC(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 1616
"apoorv" <ar**********@nospam.quark.com> wrote in message
news:93******************************@localhost.ta lkaboutprogramming.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 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 BITMAPINFO and
CreateDibSection...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
1180
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
4896
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...
13
4547
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: {<...
1
1203
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...
0
866
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...
3
63293
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...
16
1930
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; ...
1
1137
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...
3
22318
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...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
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...
0
7357
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...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
402
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...

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.