| | |
rotate a TBitmap using scanlines?!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2007
Posts: 23
Reputation:
Solved Threads: 0
hello!
im trying to rotate a tbitmap image using scanlines, and cant figure out how to do it!
ive go it working moving pixel by pixel but i want to be able to speed it up using scanlines.
im using borland 6 C++, and doin some reasearch they (borland) gave away this sample of code of their website that does exactly it, but its in pascal and ive had trouble trying to convert the language =(
ive included the file you get from the site which does it, if anyone can help translate!
thanks alot =)
Edit:
oh and if your sceptical of the file, you can download it direct or see it etc here
http://codecentral.borland.com/Item/13804
im trying to rotate a tbitmap image using scanlines, and cant figure out how to do it!
ive go it working moving pixel by pixel but i want to be able to speed it up using scanlines.
im using borland 6 C++, and doin some reasearch they (borland) gave away this sample of code of their website that does exactly it, but its in pascal and ive had trouble trying to convert the language =(
ive included the file you get from the site which does it, if anyone can help translate!
thanks alot =)
Edit:
oh and if your sceptical of the file, you can download it direct or see it etc here
http://codecentral.borland.com/Item/13804
Last edited by OnIIcE; Feb 15th, 2008 at 5:45 pm.
•
•
Join Date: Dec 2007
Posts: 23
Reputation:
Solved Threads: 0
hi thanks alot! it worked wounders! i just had to change a couple of things to make it work in borland! =D
thanks very muchly =)
would it be easy to translate the reverse function (using scan lines)?
if its to much trouble thats find since you help me lots! i spent hours thursday and friday night trying to do that!!
i think its just this function:
thanks very muchly =)
would it be easy to translate the reverse function (using scan lines)?
if its to much trouble thats find since you help me lots! i spent hours thursday and friday night trying to do that!!
i think its just this function:
C++ Syntax (Toggle Plain Text)
FUNCTION FlipReverseScanLine(CONST Flip, Reverse: BOOLEAN; CONST Bitmap: TBitmap): TBitmap; VAR i : INTEGER; j : INTEGER; RowIn : pRGBArray; RowOut: pRGBArray; BEGIN IF Bitmap.PixelFormat <> pf24bit THEN RAISE EBitmapError.Create('Can Flip/Reverse only 24-bit bitmap'); RESULT := TBitmap.Create; RESULT.Width := Bitmap.Width; RESULT.Height := Bitmap.Height; RESULT.PixelFormat := Bitmap.PixelFormat; FOR j := 0 TO Bitmap.Height-1 DO BEGIN RowIn := Bitmap.Scanline[j]; IF Flip THEN RowOut := RESULT.Scanline[Bitmap.Height - 1 - j] ELSE RowOut := RESULT.Scanline[j]; // Optimization technique: Use two FOR loops so IF is outside of inner loop IF Reverse THEN BEGIN FOR i := 0 TO Bitmap.Width-1 DO RowOut[i] := RowIn[Bitmap.Width-1-i] END ELSE BEGIN FOR i := 0 TO Bitmap.Width-1 DO RowOut[i] := RowIn[i] END END END {FlipReverseScanLine};
•
•
Join Date: Dec 2007
Posts: 23
Reputation:
Solved Threads: 0
true, it was lazy of me to ask! but ive tried now, and i keep getting a error when the code runs saying that the scanline is out of range!
this what ive got to reverse/mirror the image
edit:
ive amended my code slightly, and now i dont have a error, it just messes the picture up lots!
edit2:
ahhh ive realised my mistake! i was minusing j instead of i !!!!
thanks alot again =)
this what ive got to reverse/mirror the image
C++ Syntax (Toggle Plain Text)
for(int j=0; j < (ImgHeight-1);j++) { rowIn = (S_PixelColours*)OrigImg->ScanLine[j]; rowOut = (S_PixelColours*)result->ScanLine[j]; for(int i=0; i<(ImgWidth-1);i++) { rowOut[i] = rowIn[ImgWidth-1-j]; }
ive amended my code slightly, and now i dont have a error, it just messes the picture up lots!
edit2:
ahhh ive realised my mistake! i was minusing j instead of i !!!!
thanks alot again =)
Last edited by OnIIcE; Feb 16th, 2008 at 3:58 pm.
![]() |
Other Threads in the C++ Forum
- Previous Thread: Storing Words from Text File in Array
- Next Thread: books on using vs c++2008, the IDE , not C++ itself
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






