Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ Bmp

Status
Not open for further replies.

Carvalho

Instructor
Mar 30, 2003
1
BR
Who can i flip Horizontal and vertical a bmp file ?

thanks!!
 
Your question is not clear.
Pl. rephrase the question properly. In case u want to view any graphics file u can use any available shareware viewer or write your own viewer using the various file formats available on the net.

 
I just copied and pasted this code from bytamin-c.com. It will rotate a bitmap 90 degrees.

The code works this way; it creates a buffer image to store the proceedings, then takes each line of the image and changes it as a column on the buffer image. Finally, it transfers the result back to the original image.

//definitions of a buffer bitmap and the clipping rectangles
Graphics::TBitmap *bufferbitmap=new Graphics::TBitmap();
bufferbitmap->Width=Image1->Height;
bufferbitmap->Height=Image1->Width;

static TRect sourcepix,destpix,fullbufferimage,fulldestimage;
fullbufferimage.Left= 0;
fullbufferimage.Top= bufferbitmap->Height;
fullbufferimage.Right= bufferbitmap->Width;
fullbufferimage.Bottom= 0;


//rotate and copy the original image, pixel by pixel, to the buffer image (look at the changes in the //coordinates of sourcepix and destinationpix).

for (int y=0; y<Image1->Height; y++){
for (int x=0; x<Image1->Width; x++){
sourcepix.Left= x;

sourcepix.Top= y+1;

sourcepix.Right= x+1;

sourcepix.Bottom= y;

destpix.Left=y;

destpix.Top=bufferbitmap->Height-x;

destpix.Right=y+1;

destpix.Bottom=bufferbitmap->Height-x-1;

bufferbitmap->Canvas->CopyRect(destpix,Image1->Canvas,sourcepix);

}
}


//adjust the original image to the new dimensions and

//copy the buffered rotated image to the original image

Image1->Width=bufferbitmap->Width;

Image1->Height=bufferbitmap->Height;

Image1->Picture->Bitmap->Width=bufferbitmap->Width;

Image1->Picture->Bitmap->Height=bufferbitmap->Height;

Image1->Canvas->CopyRect(fullbufferimage, bufferbitmap->Canvas, fullbufferimage);
Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top