0

so what i am trying to do is to make fseek return to a new line as long as its smaller than factor i need to resize with. so fseek retruns to a start of line as long as its need to print those vertical resized pixels. sadly i get polarized image(one half black, other green) and thats it. or_ is original value.

am not sure how exactly am i failing at this so much can anyone point me in a right direction? thanks

1 Answer 1

1

by

fseek(inptr, (sizeof(RGBTRIPLE) * or_Width) + or_padding, SEEK_SET);

you move cursor back to the very beginning of the file (SEEK_SET), and then move it to the beginning of the next row (sizeof(RGBTRIPLE) * or_Width) + or_padding).

instead, you AT FIRST need to fill the first row in the way you do,

THEN(!!!) add new padding

THEN move cursor back to the beginning of the row (start from the current position SEEK_CUR and moving back, as fseek() allows to move in both directions)

And repeat n times. Then proceed to the next row of inptr.

5
  • thank you for your input. i changed code. it resizes large.bmp and smiley.bmp perfectly but when i try to resize small.bmp i get garbage. any idea why?
    – Belutak
    Aug 3, 2017 at 12:59
  • most probably it's padding problem, as large and smiley has zero padding while small not. Either you skip the old one incorrectly, or calculate/add the new one incorrectly, difficult to say without the code.
    – obesman
    Aug 3, 2017 at 13:26
  • i've added padding caluculation if you could glance and point if anything looks odd to you, i dont see anything wrong with the way i calculated them
    – Belutak
    Aug 3, 2017 at 15:44
  • well, it is, as expected, padding issue. Calculations seem OK. But. Lets look at the cursor in inptr for n ==1. You read the first row. Then skip old padding (in this logic you don't need to, because anyway you go to the very begging by SEEK_SET). Then go to the beginning, i now == 1, you skip the first row BUT WITHOUT old padding. So you start next read from the old padding's (0x00)
    – obesman
    Aug 3, 2017 at 16:53
  • finally with your help i brute forced it: fseek(inptr, (54 + (i * ((sizeof(RGBTRIPLE) * or_Width) + or_padding))), SEEK_SET); am not pleased how i've done it, there must be many more elegant ways but i am sick of it and it works.. thank you so much for your time and insight
    – Belutak
    Aug 4, 2017 at 10:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .