GithubHelp home page GithubHelp logo

avvessalom / itmo-low-level-programming Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 91 KB

Лабораторные работы по Низкоуровневому программированию (ИТМО, ПИиКТ-СиППО, 3 курс).

Assembly 24.90% Python 20.97% Makefile 3.03% C 51.10%

itmo-low-level-programming's People

Contributors

avvessalom avatar

Stargazers

 avatar

Watchers

 avatar  avatar

itmo-low-level-programming's Issues

padding

ты его тут не учитываешь
for (int row = 0; row < header.biHeight; row++){
for (int col = 0; col < header.biWidth; col++){
in_bmp->data[row * header.biWidth + col] = *(struct pixel *) ((data) + sizeof(struct pixel) * (row * header.biWidth + col) + padding * row);
}
}
паддинг это просто мусор, который добавляют в конец строки чтоб она делилась на 4, то есть тебе надо скипать этот мусор

for (int row = 0; row < header.biHeight; row++){
for (int col = 0; col < header.biWidth; col++){
in_bmp->data[row * header.biWidth + col] = *(struct pixel *) ((data) + sizeof(struct pixel) * (row * header.biWidth + col) + padding * row);
}
//вот тута
}

malloc

Зачем ты выделяешь память для маленьких структур типа struct img?
in_bmp = (struct img *) malloc(sizeof(struct img));

0x4d42

header->bfType = 19778; // 4D42 (little-endian)

header->bfType = 0x4D42;

read_bmp

Я бы разделил эту функцию на части чтения хедеров и самой картинки

padding2

А в случае записи надо его учитывать
fwrite(data, 1, (out_bmp->width + padding) * out_bmp->height * sizeof(struct pixel), file);
Тут у тебя все пиксели пихаются без учета паддинга и в итоге нужные пиксели считаются мусорными

create_image

Для большей расширяемости стоит сделать функцию генерирующую struct image, чтоб если ты менял ее, было видно где надо код переписать

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.